sed to remove newlines?
Kartik Subbarao
subbarao at phoenix.Princeton.EDU
Thu May 30 11:20:14 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? We have tried various things without success:
>
>escaping \n -> \\n
>double escaping \n -> \\\n
>using \012
>
>but with no success. Our man page incs. the following:-
>
>"\n Matches a NEWLINE embedded in the pattern space. "
>
ugh, sed..
>If this can only be used for pattern matching but not exchange, it would seem
>to offer nothing over the use of $.
>
>[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).]
I can do this without thinking in perl :-) :
perl -ne 'chop if (/:$/); print;'
sed....umm, I tried a bunch of line-noise-like looking things, none of
which worked. For some reason I couldn't get everything except the
terminating newline in a pattern. Oh well, I'm sure tons of other people
know how :-)
-Kartik
sed -nm
--
internet% whoami
subbarao at phoenix.Princeton.EDU -| Internet
kartik at silvertone.Princeton.EDU (NeXT mail)
SUBBARAO at PUCC.BITNET - Bitnet
More information about the Comp.unix.shell
mailing list