Thank you all for your responses. I will carefully study the suggestions  provided. sam is new to me and I am trying hard to learn it.  There are obvious errors in the script I provided and I apologise for those. I could as Rob suggested simply apply the ed script, but I am trying to learn sam's way of doing things.  As for % ssam -f thatscriptofyours somefile It gave me this error: bash: fg: %: no such job Here is the ed script : g/\*/s///g # g/[0-9]/s///g g/ *$/s/// g/ */s// /g g/\(‘‘\|’’\)/s//"/g g/\(“\|”\)/s//"/g g/\(‘\|’\)/s//'/g g/\\p/s//\ \ \ /gp g/\\b/s//\ \ \ /gp g/^ */s/// v/./.,/./-1j # Replace two or more blank lines with a single blank line in Ed wq ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T10b1d559ae7d981e-M20a4b0b4cf349f08a5bc0e9d Delivery options: https://9fans.topicbox.com/groups/9fans/subscription