1834481 Members
3404 Online
110067 Solutions
New Discussion

Replacing Entire Line

 
SOLVED
Go to solution
Pando
Regular Advisor

Replacing Entire Line

Dear Gurus,

I have a line in my files written as,

..
Diffusion Lot ID,
..

In some files, it is written as

..
Diffusion Lot ID, 11111-11
..

I want to standardize them by writing it
like the latter (Diffusion Lot ID,11111-11).
There are a thousands of them and i really need to make it quick.

Maximum points for all correct replies.
Thanks
3 REPLIES 3
Noel Miranda
Frequent Advisor
Solution

Re: Replacing Entire Line

awk '/^Diffusion Lot ID,$/ {print "Diffusion Lot ID, 11111-11"}' existingfile > newfile
Indira Aramandla
Honored Contributor

Re: Replacing Entire Line

Hi Fernando,

You can do this way as well. For Eg: your file is called test_file1

do this

cat test_file1 | awk '{print $1,$2,$3 "11111-11"}' > test_file2

Your test_file2 will have all lines as

Diffusion Lot ID, 11111-11
Diffusion Lot ID, 11111-11


Indira A

Never give up, Keep Trying
Joseph Loo
Honored Contributor

Re: Replacing Entire Line

hi,

try this:

# sed 's/Diffusion Lot ID/Diffusion Lot ID, 11111-11/' > newfile

regards.
what you do not see does not mean you should not believe