sed to remove newlines?

Rouben Rostamian rouben at math16.math.umbc.edu
Thu May 30 10:55:48 AEST 1991


In article <6356 at iron6.UUCP> yeates at motcid.UUCP (Tony J Yeates) writes:
|Is it possible to remove newlines (i.e. \n) from a file using sed?  If
|so how?
|...
|[Our current requirement is to concatenate any lines ending with a ':' to  the
|next line in a file.   Although I can think of numerous other uses ( we
|usually end up using tr '\012' '<some char.>' as a work around).]

To concatenate lines ending in a ':' to the following line using sed, do:

sed '/:$/{N; s/\n//; }' <infile >outfile

--
Rouben Rostamian                          Telephone: (301) 455-2458
Department of Mathematics and Statistics  e-mail:
University of Maryland Baltimore County   bitnet: rostamian at umbc.bitnet
Baltimore, MD 21228,  U.S.A.              internet: rouben at math9.math.umbc.edu



More information about the Comp.unix.shell mailing list