January 7th, 2013, 01:33 PM
Mass file edit
I am trying to mass edit a bunch of files using sed . Below is what I have in my script
Some sentence # comment
I need to add a new line after the "Some sentence" and add a new sentence there for all the files in the directory. As of now I am trying to do the following
sed -i -e "s/Some sentence\t# comment/Some sentence\t# comment\nNew Sentence"
Is there an easy way to do this inseatd of replacing sentence1 and then adding sentence 1\nsentence 2
January 8th, 2013, 07:14 AM
You should be able to use a 'back reference' in the replacement:
Originally Posted by man page
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc