The UNIX command "sed", "awk", and "tr" offer a world of solutions for altering text.
 
Using Ksh93 you can do substringing.  You can find it on Aix, and Sun system in the form of "dtksh".  The syntax is:
 
    #!/usr/dt/bin/dtksh
    ...cut...
    myvar=${myvarin:startpos:length}
    ...rest...
 
To edit a file on the fly use the old "edit" command.  An example follows:
 
    3925:oratst@marge> cat /tmp/abc
    aaaaaaaaaaaabbbbbbbbbbbbbbbbbccccccccccccccc
    $HOSTNAME$.$SCHEMA$
    11111111111112222222222222222223333333333333
    3925:oratst@marge>
    3925:oratst@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@marge>
    3925:oratst@marge>
    3925:oratst@marge> cat /tmp/abc
    aaaaaaaaaaaabbbbbbbbbbbbbbbbbccccccccccccccc
    MYBOX.MYSCHEMA
    11111111111112222222222222222223333333333333
    3925:oratst@marge>
    3925:oratst@marge>
-----Original Message-----
From: Big Planet [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 23, 2001 6:56 PM
To: Multiple recipients of list ORACLE-L
Subject: 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
 

 

Reply via email to