Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!elroy.jpl.nasa.gov!sdd.hp.com!news.cs.indiana.edu!att!princeton!phoenix.Princeton.EDU!subbarao From: subbarao@phoenix.Princeton.EDU (Kartik Subbarao) Newsgroups: comp.unix.shell Subject: Re: sed to remove newlines? Message-ID: Date: 30 May 91 01:20:14 GMT References: <6356@iron6.UUCP> Sender: news@idunno.Princeton.EDU Reply-To: subbarao@phoenix.Princeton.EDU (Kartik Subbarao) Distribution: comp.unix.shell Organization: American Chemical Society Lines: 41 In article <6356@iron6.UUCP> yeates@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' '' 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@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet