I am seeking help to copy a file - with the changes (not just the changes) - to a new file. I have a text file that contains numerous lines of text as given below -
Name ABC.DEF.GHI Adrs (tcp) Port (53) CONN(xyz) #Name ABC.DEF.GHI Adrs (tcp) Port (53) CONN(xyz)
Name GHI.JKL.MNO Adrs (tcp) Port (53) CONN(abc) #Name GHI.JKL.MNO Adrs (tcp) Port (53) CONN(abc)
I wish to copy the <infile> to <outfile> with some changes, say using the following -
grep ABC <file> | grep CONN | grep -v "#" | sed /s/xyz/abc > [outfile]
But the above line copies only the fetched & amended data to the new file. But, I want to copy all the lines + the amendments that I make.
Can someone help me on this? Thanks a bunch in advance.
No the above awk line did not work. It throws "awk : syntax error". However, I removed the gsub function and used {print $0} instead and it returns the correct line. But, substitution is NOT working. Can u plz check ?
Hi rdcwayx,
nawk worked well in the example above.
But, It did not work with the following line,
DEFINE CHNL(TO.ABC.DEF) CHLTYPE(SDR) XMITQ(ABC.TRANS.Q) TRPTYPE(tcp) CONNAME('abcghij.pqr.com(1010)') REPLACE
I wanted to repalce the abcghij after CONNAME to say, pqrstuv.
I really cant figure it out why it did not work. Sorry for the trouble.