deleting some empty lines with sed
Lou Kates
louk at tslwat.UUCP
Mon Apr 29 13:47:15 AEST 1991
In article <1991Apr27.143519.26256 at daimi.aau.dk> datpete at daimi.aau.dk (Peter Andersen) writes:
>If two or more blank lines appear, I want to remove all but
>one of these.
The following awk script (its called nawk on my system) will do
this:
nawk 'NF || !b; {b = !NF}'
b is a flag which is true if the previous input line was blank.
The first statement of the script prints the current line if it
has fields or if b is false (or null as it will be on the first
line of input). The second statement of the script sets b.
Lou Kates, Teleride Sage Ltd., louk%tslwat at watmath.waterloo.edu
More information about the Comp.unix.shell
mailing list