2009/2/13

sed: How to

sed -n '2p' haha.dat => print the 2nd line in haha.dat
sed -n '3,4p' haha.dat => print the line 3th to 4th in haha.dat
sed -e '/^aaa bbb/s/source/object/' => find the first word is "aaa ddd" then substitute source to object.

sed -i -e '1,7 {/^READ BLOCK/s/".*\.dat"/"'$file_name'"/}'
-e 's/".*\.jpg"/"e_He_gif_sourcesink_Te_'$JPGNAME'\.jpg"/' $plot_batch

sed -n '3~5;' haha.dat => print from line 3 then every 5 line print (3,8,13,18.... will print)