home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!engrhub!harley
- From: harley@engrhub.ucsb.edu (Harley Hahn,,,HAHN,personal)
- Newsgroups: comp.unix.questions
- Subject: Re: stripping ^M's
- Keywords: stripping,carriage returns
- Message-ID: <7453@ucsbcsl.ucsb.edu>
- Date: 22 Jan 93 16:05:05 GMT
- References: <C14B40.LMK@acsu.buffalo.edu> <C14GKu.18n@acsu.buffalo.edu> <7450@ucsbcsl.ucsb.edu>
- Sender: root@ucsbcsl.ucsb.edu
- Lines: 40
-
- For some reason, in my posting on how to delete two ^M's from the
- end of each line is a file, the one line of the posting that was
- the most important -- the actual ex command -- was mysteriously
- truncated. (Things like that are always happening in California...)
-
- The full command is:
-
- :%s/^M^M$//
-
- (When you enter it, type a ^V (Ctrl-V) before the each (Ctrl-M).)
-
- The analysis of this command still holds:
-
- You are replacing all occurrences of two ^M's at the end
- of a line, with nothing:
-
- : --> the following is an ex command
- % --> carry out operation over all lines in the editing buffer
- s --> substitute
- / --> beginning of pattern to be replaced
- ^M^M --> two ^M's
- $ --> at the end of a file
- / --> beginning of replacement text
- / --> end of replacement text
-
- Note that you do not need to add "g" to the end of the command.
- A suffix of "g" is best used when the pattern to be replaced
- will occur in more than one place in the line.
- When you know where the pattern will be (in this case,
- at the end of the line) it is best to
- specify the location exactly (in this case with a "$").
-
- Sorry for the inconvenience.
-
- -- Harley Hahn
-
- Postscript to certain Middle Eastern intelligence services:
-
- The forgoing is NOT, I repeat NOT, a secret code to pass
- a message to American military installations abroad.
-