sed script to combine blank lines?

George Young young at vlsi.ll.mit.edu
Thu Oct 13 07:13:32 AEST 1988


Is there a 'sed' wizard out there?  I often want to take a big ascii file
(like a .c file after cc -E) and collapse each group of 'blank' lines
into exactly one blank line.  'Blank' here is any combination of blanks,
tabs and maybe ^L's.  It looks from the documentation that sed should do this
quite neatly, using the multiple line pattern space commands with imbedded
newlines, but I sure can't figure out how.  I'd prefer the resulting blank
line to be just a newline.

I know there are various other unix tools that could do this, but sed looks
like the most appropriate, and I would like to learn to use it's fancier
facilities anyway.

Any ideas?  Just email response if this seems too trivial for broad posting.


George Young,  Rm. B-141		young at ll-vlsi.arpa
MIT Lincoln Laboratory			young at vlsi.ll.mit.edu
244 Wood St.
Lexington, Massachusetts 02173		(617) 981-2756
.
-- 
George Young,  Rm. B-141		young at ll-vlsi.arpa
MIT Lincoln Laboratory			young at vlsi.ll.mit.edu
244 Wood St.
Lexington, Massachusetts 02173		(617) 981-2756



More information about the Comp.unix.questions mailing list