Re: adding lines

From: Radoulov, Dimitre <cichomitiko_at_gmail.com>
Date: Wed, 16 Dec 2009 12:42:18 +0100
Message-ID: <4B28C79A.5010509_at_gmail.com>



On 16/12/2009 12.16, Noor Mulla wrote:
>
> Anyone in the position to convert below script which is using *sed* to
> a script using *awk*. Basically, we are adding *unrecoverable, path
> ddumps/../../dataciti_master *and* append* to existing ctl files. This
> is very urgent.
>
> for FILE in `ls -1 *.test`
>
> [...]
>

I believe this is off-topic here ...
Anyway (backup your data before running the script, or just change /mv /to /cp/):

awk 'END { close(fn); system("mv " fn " " ofn) } FNR == 1 {
   if (fn) { close(fn); system("mv " fn " " ofn) }    print "unrecoverable" > (fn = FILENAME "__new")    ofn = FILENAME
   }
{

   sub(/infile \47/, "&/DDUMPS/sybase_dump/out/DATACITI_MASTER/Oracle/")    /into table/ && $0 = "append " $0; print > fn    }' *.ctl

Use /gawk/, /nawk /or/ /usr/xpg4/bin/awk/ on /Solaris/. Do not use //usr/bin/awk/ on /Solaris /:)

The /Perl /version would be shorter, but you want /AWK /:)

Regards
Dimitre

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Dec 16 2009 - 05:42:18 CST

Original text of this message