Path: utzoo!attcan!uunet!tank!ncar!ames!mailrus!purdue!decwrl!hplabs!hp-sdd!allyn From: allyn@hp-sdd.hp.com (Allyn Fratkin) Newsgroups: comp.unix.questions Subject: Re: sed script to combine blank lines? Message-ID: <1577@hp-sdd.HP.COM> Date: 16 Oct 88 22:37:20 GMT References: <192@vlsi.ll.mit.edu> Sender: netnews@hp-sdd.HP.COM Distribution: comp Lines: 22 you sed experts are going way overboard here. this is a really trivial problem for sed. try something simple, like the following: sed 's/^[]*//; /^$/N; /^\n[]*$/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@sdd.hp.com San Diego Division - or - Hewlett-Packard Company uunet!ucsd!hp-sdd!allyn