Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Unix question

RE: Unix question

From: Brian MacLean <bmaclean_at_vcommerce.com>
Date: Mon, 26 Mar 2001 07:45:00 -0800
Message-ID: <F001.002D7CA9.20010326072534@fatcity.com>

<SPAN

class=948131115-26032001>The UNIX command "sed", "awk", and "tr" offer a world of solutions for altering text.
<SPAN

class=948131115-26032001> 
<SPAN

class=948131115-26032001>Using Ksh93 you can do substringing.  You can find it on Aix, and Sun system in the form of "dtksh".  The syntax is:
<SPAN

class=948131115-26032001> 
<SPAN

class=948131115-26032001>   
#!/usr/dt/bin/dtksh
<SPAN

class=948131115-26032001>    ...cut...
<SPAN

class=948131115-26032001>   
myvar=${myvarin:startpos:length}
<SPAN

class=948131115-26032001>    ...rest...
<SPAN

class=948131115-26032001> 
<SPAN

class=948131115-26032001>To edit a file on the fly use the old "edit" command.  An example follows:
<SPAN

class=948131115-26032001> 
<SPAN

class=948131115-26032001>    3925:oratst_at_marge> cat /tmp/abc   

aaaaaaaaaaaabbbbbbbbbbbbbbbbbccccccccccccccc    
$HOSTNAME$.$SCHEMA$   
11111111111112222222222222222223333333333333    
3925:oratst_at_marge>
<SPAN

class=948131115-26032001>    3925:oratst_at_marge> edit /tmp/abc
<<\EOF    >

1,$s/\$HOSTNAME\$/MYBOX/g    >
1,$s/\$SCHEMA\$/MYSCHEMA/g    > w   
> q    > EOF    "/tmp/abc" 3 lines, 
110 characters    MYBOX.$SCHEMA$    
MYBOX.MYSCHEMA    "/tmp/abc" 3 lines, 105 
characters    3925:oratst_at_marge>   
3925:oratst_at_marge>    3925:oratst_at_marge> cat /tmp/abc   
aaaaaaaaaaaabbbbbbbbbbbbbbbbbccccccccccccccc    
MYBOX.MYSCHEMA   
11111111111112222222222222222223333333333333    
3925:oratst_at_marge>   
3925:oratst_at_marge>

  <FONT face=Tahoma
  size=2>-----Original Message-----From: Big Planet   [mailto:bigplanet34_at_hotmail.com]Sent: Friday, March 23, 2001 6:56   PMTo: Multiple recipients of list ORACLE-LSubject: Unix   question
  Hi geeks ,
  How can I do substr and instr kind of operaion in   unix shell script . is it possible ?
  like i have one paramter as "hostname" .. I want   to trim quotes surrounding the hostname .   One more question , is possible to read another   text file line by line using a shel script and then edit that file   .
  Actually I have this configuration file for my   system which have keywords like $HOSTNAME$ , $SCHEMA$ which I want to replace   with actual values at the time of installation by asking questions to the   user.
   
  TIA
  --Big planet
   
    Received on Mon Mar 26 2001 - 09:45:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US