sed script to combine blank lines?
Allyn Fratkin
allyn at hp-sdd.hp.com
Mon Oct 17 08:37:20 AEST 1988
you sed experts are going way overboard here. this is a really
trivial problem for sed. try something simple, like the following:
sed 's/^[<sp><tab><ff>]*//; /^$/N; /^\n[<sp><tab><ff>]*$/D'
this starts by reducing a "blank" line to an empty one. an empty
line is joined to the next line, and then if this next line is also
"blank", the first line is deleted.
i admit that this does require non-printable chars. too bad sed
doesn't understand octal escape sequences.
to get around the non-printable chars, you could always do something
like this:
chars=`echo '\040\011\014\c'` # use -n with bsd echo
sed "s/^[$chars]*//; /^$/N; /^\n[$chars]*$/D"
--
From the virtual mind of Allyn Fratkin allyn at sdd.hp.com
San Diego Division - or -
Hewlett-Packard Company uunet!ucsd!hp-sdd!allyn
More information about the Comp.unix.questions
mailing list