Path: utzoo!utgpu!water!watmath!clyde!att!alberta!uofaee!adec23!mark From: mark@adec23.UUCP (Mark Salyzyn) Newsgroups: comp.unix.questions Subject: Re: sed script to combine blank lines? Keywords: sed Message-ID: <1623@adec23.UUCP> Date: 17 Oct 88 15:57:25 GMT References: <192@vlsi.ll.mit.edu> Distribution: comp Organization: ADEC Systems Inc., Edmonton, Alberta Lines: 22 In article <192@vlsi.ll.mit.edu>, young@vlsi.ll.mit.edu (George Young) writes: > 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. This is untested, but you should get the idea ... : loop N /^[(blank)(tab)(form feed)]*\n[(blank)(tab)(form feed)]*$/ { s/// b loop } Replace (blank) with the blank character itself. Replace (tab) with the tab character itself. Replace (form feed) with the form feed character itself. -- Mark Salyzyn @ ADEC Systems Inc.