home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15847 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  1.7 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!engrhub!harley
  2. From: harley@engrhub.ucsb.edu (Harley Hahn,,,HAHN,personal)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: stripping ^M's
  5. Keywords: stripping,carriage returns
  6. Message-ID: <7453@ucsbcsl.ucsb.edu>
  7. Date: 22 Jan 93 16:05:05 GMT
  8. References: <C14B40.LMK@acsu.buffalo.edu> <C14GKu.18n@acsu.buffalo.edu> <7450@ucsbcsl.ucsb.edu>
  9. Sender: root@ucsbcsl.ucsb.edu
  10. Lines: 40
  11.  
  12. For some reason, in my posting on how to delete two ^M's from the
  13. end of each line is a file, the one line of the posting that was
  14. the most important -- the actual ex command -- was mysteriously
  15. truncated.  (Things like that are always happening in California...)
  16.  
  17. The full command is:
  18.  
  19. :%s/^M^M$//
  20.  
  21. (When you enter it, type a ^V (Ctrl-V) before the each (Ctrl-M).)
  22.  
  23. The analysis of this command still holds:
  24.  
  25. You are replacing all occurrences of two ^M's at the end
  26. of a line, with nothing:
  27.  
  28. :     --> the following is an ex command
  29. %     --> carry out operation over all lines in the editing buffer
  30. s     --> substitute
  31. /     --> beginning of pattern to be replaced
  32. ^M^M  --> two ^M's
  33. $     --> at the end of a file
  34. /     --> beginning of replacement text
  35. /     --> end of replacement text
  36.  
  37. Note that you do not need to add "g" to the end of the command.
  38. A suffix of "g" is best used when the pattern to be replaced
  39. will occur in more than one place in the line.
  40. When you know where the pattern will be (in this case,
  41. at the end of the line) it is best to
  42. specify the location exactly (in this case with a "$").
  43.  
  44. Sorry for the inconvenience.
  45.  
  46. -- Harley Hahn
  47.  
  48. Postscript to certain Middle Eastern intelligence services:
  49.  
  50. The forgoing is NOT, I repeat NOT, a secret code to pass
  51. a message to American military installations abroad.
  52.