How to remove ^M's from a file (CLEAN)
To remove '^M' (control-M) characters from the end of each line in a file, you
can use a shell script called 'clean'.
To use the shell script, you first need to attach the Consultants' Software
Library to your workstation. Use this command:
add consult
Now you can type this command:
clean filename > newfilename
...where 'filename' is the name of the file containing the '^M' characters,
and 'newfilename' is the name of the file that you want the 'clean' script to
create.
The script takes 'filename' as input, changes each ^M to a newline character,
and directs the output to the new file called 'newfilename'. You can check
that the new file contains no '^M' characters by viewing it with this command:
cat -v newfilename
You can also remove all the control-M characters inside Emacs, though
it's a little tricky because Emacs tries to be helpful and treat
different OS-style line breaks transparently. To use Emacs to make
the replacement, follow these steps:
1. type:
C-x RET C undecided-unix RET C-x C-w RET y
2. go to the beginning of the document
3. type:
M-x replace-string RET C-q C-m RET RET
where "RET" means <press the RETURN key> and things like C-q mean
"hold control key and press the q" key.
|