Bonno Bloksma wrote: > Have been experimenting some with it but... > > linbobo:~/sedtest# sed 's_<pre>_<post>_' <original.txt >new.txt > linbobo:~/sedtest# less new.txt > > And indeed I will see <post> on that line instead of <pre> but... > > linbobo:~/sedtest# sed 's_\n<pre>\n_\n<pre>\n\n_' <original.txt >new.txt > linbobo:~/sedtest# less new.txt > > Will not create a new line after <pre> :-(
Using sed is a good tool for this but if you want to append then you should use the 'a' command. $ printf "one\ntwo\nthree\nfour\n" one two three four $ printf "one\ntwo\nthree\nfour\n" | sed '/two/a\ -> foo' one two -> foo three four But using Perl (or Ruby or Python or ...) is also easy. $ printf "one\ntwo\nthree\nfour\n" | perl -lne 'print $_; print "-> foo" if $_ =~ m/two/' one two -> foo three four Bob
signature.asc
Description: Digital signature