home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!ferkel.ucsb.edu!taco!mamushka.ncsu.edu!fester
- From: fester@mamushka.ncsu.edu (Cousin It)
- Subject: SED GURUS: Some Newline Questions
- Message-ID: <1992Sep10.230603.1267@ncsu.edu>
- X-Disclaimer: none
- Keywords: sed newline
- Lines: 54
- Sender: news@ncsu.edu (USENET News System)
- Nntp-Posting-Host: thing.mamushka.ncsu.edu
- Reply-To: fester@mamushka.ncsu.edu (Cousin It)
- Organization: North Carolina State University
- Date: Thu, 10 Sep 1992 23:06:03 GMT
-
-
- Hi sed people. For a project I'm working on, I'm trying to
- figure out how to insert newlines in sed. Man pages were
- virtually useless, although I did determine that the "N"
- might be necessary. Here's the scenario:
-
- 1) In the input text, lines ending with a semicolon need to have
- a right bracket and newline inserted:
-
- --before--
- start
- { THIS IS LINE 1;
- { THIS IS LINE 2;
- end
-
- --after--
- start
-
- { THIS IS LINE 1; }
-
- { THIS IS LINE 2; }
-
- end
-
- I've got this much:
-
- sed -e 's/;$/; \}/'
- ^necessary?
-
- Adding \n, \\n, or \\\n was fruitless.
-
-
- 2) Next, I need to delete a newline from text:
-
- --before--
- start
- TITLE 1 | |
- subtopic
-
- end
-
- --after--
- start
- TITLE 1 | | subtopic
-
- end
-
- Any ideas? I've tried rewriting the whole thing in awk and perl,
- but it didn't work properly in awk, and I don't know perl well
- enough to get the thing to work in perl, although I did try the
- s2p program. Awk was a _lot_ easier to learn than perl,
- at least for me...
-
- "fester"
-