1835989 Members
2502 Online
110088 Solutions
New Discussion

Re: help script

 
Jairo Campana
Trusted Contributor

help script

hello i have a file wiht field : prog and base
file: test
cat test
pro=
xxxx
xxxx
base:

I need add in pro= the contains of file: test2
cat test2
pp.pp@pp.com
...
and add in base: the contains of file :test3
cat test3
pp.ogt@ko.com
...

script :
fo i in `test1`
do
cat test |sed.
legionx
6 REPLIES 6
Rodney Hills
Honored Contributor

Re: help script

How about the following-

perl -n -e 'BEGIN{@test2=`cat test2`;@test3=`cat test3`}{if (/^pro=/) { print @test2;} elsif (/^base:/) { print @test3;} else { print $_}}' test >newtest

HTH

-- Rod Hills
There be dragons...
Sandman!
Honored Contributor

Re: help script

How about an ex construct:

ex -s test </^pro=/r !cat test2
/^base:/r !cat test3
wq
EOF

and output of the above construct is...

cat test
pro=
pp.pp@pp.com
xxxx
xxxx
base:
pp.ogt@ko.com

hope it helps!
Jairo Campana
Trusted Contributor

Re: help script

the ouput will have to be:

cat test
pro=xxx
base=pp.ogt@ko.com
legionx
Rodney Hills
Honored Contributor

Re: help script

pro=xxx ???

I thought you wanted pro= to have the contents of file test2 which you show as pp.pp@pp.com.

Your description of the problem is a little unclear.

Rod Hills
There be dragons...
Sandman!
Honored Contributor

Re: help script

Jairo,

Could you please provide a sample of how the input looks like and how the output should look like.

cat test
pro=xxx
base=pp.ogt@ko.com

this does not show where the contents of file test2 have been added to?
Jairo Campana
Trusted Contributor

Re: help script

Yes the file ouput it will be

cat test
pro=mail@test.com
base:mail2@test567.com

the field pro=
base:
is variable
legionx