Replace line in file with two lines?! Possible?
I'm trying to replace a single line in a file with two lines. I.e:
.... AB = 12 ... to .... AB = 12 CD = 34 .... Can this be done without reading in each line individually and then writing back to another file? I really want to avoid this method since it removes all tabbing and thus creates a horrid file with each line aligned to the far left of the page. Thanks! |
Hi,
I don't get this part: Quote:
sed -i 's/AB = 12/AB = 12\nCD = 34/' infile and the old fashion way also works: sed 's/AB = 12/AB = 12\nCD = 34/' infile > outfile This should not interfere with the layout of the file (this is also true for awk and other programs). You can manipulate those things, it's not done by default. Hope this helps. |
Code:
sed -i.bak 's/AB = 12/&\nCD = 34/' file.txt Nuts, too slow again. |
All times are GMT -5. The time now is 09:43 PM. |