home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / question / 10936 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.4 KB  |  69 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!mamushka.ncsu.edu!fester
  3. From: fester@mamushka.ncsu.edu (Cousin It)
  4. Subject: SED GURUS: Some Newline Questions
  5. Message-ID: <1992Sep10.230603.1267@ncsu.edu>
  6. X-Disclaimer: none
  7. Keywords: sed newline
  8. Lines: 54
  9. Sender: news@ncsu.edu (USENET News System)
  10. Nntp-Posting-Host: thing.mamushka.ncsu.edu
  11. Reply-To: fester@mamushka.ncsu.edu (Cousin It)
  12. Organization: North Carolina State University
  13. Date: Thu, 10 Sep 1992 23:06:03 GMT
  14.  
  15.  
  16. Hi sed people.  For a project I'm working on, I'm trying to
  17. figure out how to insert newlines in sed.  Man pages were
  18. virtually useless, although I did determine that the "N"
  19. might be necessary.  Here's the scenario:
  20.  
  21. 1)  In the input text, lines ending with a semicolon need to have 
  22.     a right bracket and newline inserted:
  23.  
  24. --before--
  25. start
  26. { THIS IS LINE 1;
  27. { THIS IS LINE 2;
  28. end
  29.  
  30. --after--
  31. start
  32.  
  33. { THIS IS LINE 1; }
  34.  
  35. { THIS IS LINE 2; }
  36.  
  37. end
  38.  
  39. I've got this much:
  40.  
  41.    sed -e 's/;$/; \}/'
  42.                   ^necessary?
  43.   
  44. Adding \n, \\n, or \\\n was fruitless.
  45.  
  46.  
  47. 2)  Next, I need to delete a newline from text:
  48.  
  49. --before--
  50. start
  51. TITLE 1 | |
  52. subtopic
  53.  
  54. end
  55.  
  56. --after--
  57. start
  58. TITLE 1 | | subtopic
  59.  
  60. end
  61.  
  62. Any ideas?  I've tried rewriting the whole thing in awk and perl,
  63. but it didn't work properly in awk, and I don't know perl well 
  64. enough to get the thing to work in perl, although I did try the
  65. s2p program.  Awk was a _lot_ easier to learn than perl, 
  66. at least for me...
  67.  
  68. "fester"
  69.