Re: adding lines

From: Waldirio Manh„es Pinheiro <waldirio_at_gmail.com>
Date: Wed, 16 Dec 2009 13:41:13 -0200
Message-ID: <7df9f1820912160741q5724f0f0p6543bd9a9a00910b_at_mail.gmail.com>



Friends

Other way

In my sample

plati:[xxx] > cat file1 | sed -e '1i\ UNRECOVERABLE' -e "s/^infile\ '/infile\ '\/DDUMPS\/sybase_dump\/out\/DATACITI_MASTER\/Oracle\//g" -e
"s/^into\ table/append\ into\ table/g"

UNRECOVERABLE
load data
infile '/DDUMPS/sybase_dump/out/DATACITI_MASTER/Oracle/DATACITI_MASTER.dbo.aspc_defaultdb.dat'
"str '<EORD>'"

append into table DATACITI_MASTER.aspc_defaultdb fields terminated by '<EOFD>'
trailing nullcols (
virtualid ,
host CHAR(255)
)

file1 content
###
load data infile 'DATACITI_MASTER.dbo.aspc_defaultdb.dat' "str '<EORD>'" into table DATACITI_MASTER.aspc_defaultdb fields terminated by '<EOFD>'
trailing nullcols
(
virtualid ,
host CHAR(255) )
###

Explanation

Really, the sed command doesn't work fine in Solaris (to append or include for example), so in the command bellow, only to include the text UNRECOVERABLE in the first line, it's necessary after 1i, you put \^J, where you can type CTRL+V CTRL+J to generate the correct code.

plati:[xxx] > cat file1 | sed -e '1i\ UNRECOVERABLE'

So, like this plati:[xxx] > cat file1 | sed -e '1i\^JUNRECOVERABLE'

Ps. Noor, sorry for delay.

Enjoy
Waldirio

On Wed, Dec 16, 2009 at 9:53 AM, Radoulov, Dimitre <cichomitiko_at_gmail.com> wrote:

> On 16/12/2009 12.42, Radoulov, Dimitre wrote:
>
> 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):
>
>
> ... and this will take care of eventual pathological characters in your ctl
> filenames.
>
>
> awk 'END { close(fn); system("mv " fn " " ofn) }
> FNR == 1 {
>   if (fn) { close(fn); system("mv \47" fn "\47 \47" ofn "\47") }
>   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
>
>
>
> Regards
> Dimitre
>
>



-- 
______________
Atenciosamente
Waldirio
msn: waldirio_at_gmail.com
Site: www.waldirio.com.br
Blog: blog.waldirio.com.br
PGP: www.waldirio.com.br/public.html
--
http://www.freelists.org/webpage/oracle-l
Received on Wed Dec 16 2009 - 09:41:13 CST

Original text of this message