Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!pdn!boake2!sherpa!rac From: rac@sherpa.UUCP (Roger A. Cornelius) Newsgroups: comp.unix.questions Subject: sed script to remove cr/lf except at paragraph breaks Keywords: sed msdos Message-ID: <119@sherpa.UUCP> Date: 19 May 89 02:26:55 GMT Distribution: na Organization: Personal System Computing, St. Petersburg, FL Lines: 10 I'm in need of a sed script to remove MSDOS cr/lf (actually replace each cr/lf combination with one space) except at the start of a paragraph. i.e. only the cr/lf preceding a paragraph break should remain. Paragraphs are marked only by four leading spaces and nothing else. Here's where I am now: N h /\n /{ P D } s/^M\n/ /g This works correctly for the first match, ie beginning of a paragraph, but for all other lines, the substitution of a space for cr/lf only works correctly for the first occurrance in the line (the g flag seems to have no effect). But there are two occurrances due to the N function. How can I match (and substitute for) the terminating nl in the pattern space? The sed man pages concerning addresses say you can't. What am I missing or how can I get around this? This is probably simple and has been covered here before. Sorry. Any help appreciated. Roger