Some handy sed examples:
http://www-h.eng.cam.ac.uk/help/tpl/unix/sed.html
From that link:
Code:
# substitute (find and replace) "foo" with "bar" on each line
sed 's/foo/bar/' # replaces only 1st instance in a line
sed 's/foo/bar/4' # replaces only 4th instance in a line
sed 's/foo/bar/g' # replaces ALL instances in a line
you have already seen the use of the
option for inserting text to the file.
Not sure what the other parts were (or if you had got confused with the sed instructions as I often do).
if I take file (tmptxt.txt):
Code:
text1 text text
text2 text text
text3 text3 text3
And run:
Code:
sed -i '2 s/text/textMARKED/' tmptxt.txt
I get:
Code:
text1 text text
textMARKED2 text text
text3 text3 text3
in your script you may need to replace single quotes with double quotes.