From jhmeyers@miu.edu Fri Sep 27 19:28:53 1996 Path: fu-berlin.de!uniol!uni-erlangen.de!news.dfn.de!news.nacamar.de!www.nntp.primenet.com!nntp.primenet.com!news.sgi.com!enews.sgi.com!news.mathworks.com!uunet!in1.uu.net!cdc2.cdc.net!vixen.cso.uiuc.edu!newsrelay.iastate.edu!news.iastate.edu!vax1.miu.edu!JHMEYERS From: jhmeyers@miu.edu (John H Meyers) Newsgroups: comp.editors Subject: Sed: using newlines as markers (reversing a line in sed) Date: 23 Sep 1996 07:23:54 GMT Organization: MIU Computer Services, Fairfield, IA 52557. Not Approved. Lines: 29 Distribution: inet Message-ID: <525dua$r4s@news.iastate.edu> References: Reply-To: jhmeyers@miu.edu NNTP-Posting-Host: vax1.mum.edu In article <...astoundingly long string...>, Casper BodenCummins writes: [ snipped a script containing "@@" here and there ] > The @@ symbols are used as markers. Obviously I'd prefer to use \n if I > could, but I can't see a generic way of doing so. It's something of a > drawback that sed doesn't offer a marker in its repertoire. You can insert newlines in any s(ubstitute) command's replacement string; just escape the literal newline with a "\" (to get one "\" into the final script sent to "sed" sometimes takes extra "\"s in a shell command); e.g. s/xxxxx/yyyyyy\ zzzzzz/ Since a newline is the only character (aside from null, which can't be used) which can not possibly occur within any original input line, it is the only "universal" marker which is always safe to use. In matching patterns, use "\n" to match newlines, e.g. /yyyyyy\nzzzzzz/ { ... This stuff works in many "sed" processing scripts I have used under Xenix, and I just checked it out again under Solaris. ----------------------------------------------------------- With best wishes from: John H Meyers ( jhmeyers@mum.edu )