Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!apple!bionet!ig!arizona!rupley From: rupley@arizona.edu (John Rupley) Newsgroups: comp.unix.questions Subject: Re: sed script to combine blank lines? Summary: use sed not awk Keywords: sed Message-ID: <7372@megaron.arizona.edu> Date: 14 Oct 88 00:30:01 GMT References: <192@vlsi.ll.mit.edu> <136@nascom.UUCP> Distribution: comp Organization: U of Arizona CS Dept, Tucson Lines: 27 In article <136@nascom.UUCP>, rar@nascom.UUCP (Alan Ramacher) writes: > In article <192@vlsi.ll.mit.edu>, young@vlsi.ll.mit.edu (George Young) writes: > > 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. > > sed is not powerful enuf for the job, but a simple awk script will > work. The following simple sed script should work (after replacing etc by the corresponding ascii characters) -- and I suspect it is shorter and will run faster than an equivalent awk script. sed "/^[]*$/{ N /\n.*[^]/{ b } D }" filename John Rupley internet: rupley@megaron.arizona.edu uucp: ..{cmcl2 | hao!ncar!noao}!arizona!rupley Dept. Biochemistry, Univ. Arizona, Tucson AZ 85721