Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!apple!bionet!agate!labrea!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: sed script to combine blank lines? (sed + awk solutions) Keywords: sed Message-ID: <1527@solo9.cs.vu.nl> Date: 14 Oct 88 20:32:04 GMT References: <192@vlsi.ll.mit.edu> <136@nascom.UUCP> <7372@megaron.arizona.edu> Reply-To: maart@cs.vu.nl (Maarten Litmaath) Distribution: comp Organization: VU Informatica, Amsterdam Lines: 39 In article <7372@megaron.arizona.edu> rupley@arizona.edu (John Rupley) writes: \sed "/^[]*$/{ \ N \ /\n.*[^]/{ \ b \ } \ D \ }" filename Four things: 1) I guess you meant , instead of . 2) The script doesn't convert lines containing []* to JUST 1 newline. 3) The script contains non-printable characters. 4) The script could have been less complex. For these reasons I suggest the following adjusted script: ------------------------------cut here---------------------------------------- #! /bin/sh chars=" `echo tf | tr tf '\11\14'`" exec sed "/^[$chars]*$/{ N /\n[$chars]*$/D s/[$chars]*// }" $* ------------------------------cut here---------------------------------------- The `awk' solution I posted earlier, had to be modified a bit too: ------------------------------cut here---------------------------------------- #! /bin/sh exec awk '$0 !~ /^[ \t\f]*$/ { print; prev = 0; next } prev == 0 { prev = 1; print "" }' $* -- Hippic sport: |Maarten Litmaath @ Free U Amsterdam: a contradiction in terms.|maart@cs.vu.nl, mcvax!botter!maart