replacing two EOL chars by one

Jesse Tov tov at eecs.harvREMOVEard.edu
Sun Dec 21 03:38:49 CET 2003


Pascal Bourguignon <spam at thalassa.informatimago.com>:
> Even with sed I find difficult to do that.

If you want to remove blank lines, then sed '/^$/d' will do.  If, on
the other hand, you actually want to compress pairs of newlines into
single newlines (as I think the specification may have said), something
a bit more complicated is required.  I think that sed 'N;P;/\n$/d;D'
will do it.

Jesse




More information about the Python-list mailing list