Notice! This document is currently in
Archived
status.
The content of this document may be incorrect or outdated.
The content of this document may be incorrect or outdated.
Print this article Edit this article
Cleaning up text files in Unix (Removing M's)
"^M" (Control M) characters appear in text files since line Breaks
from Windows get interpreted as "^M"s in Unix. One way to get rid of '^M' characters
when switching from Dos to Unix would be by typing the following DOS command:
You can then go back and delete the old filename, replacing it with the new filename.
from Windows get interpreted as "^M"s in Unix. One way to get rid of '^M' characters
when switching from Dos to Unix would be by typing the following DOS command:
dos2unix old filename (that you would like to change) new filename
You can then go back and delete the old filename, replacing it with the new filename.
Another way of removing the M's from the end of each line in a file is by using a shell script called cleanscript.
Cleanscript is a filter which fixes backspaces and carriage returns, making your file more readable.
The scrip must have the old file as input, and the new filename as output, like this:
% cleanscript <infile> outfile...where 'infile' is the name of the file containing the '^M' characters, and 'outfile' is the name of the file that you want cleanscript to create.
You can check that the new file contains no '^M' characters by viewing it with this command:
% cat -v outfile
Last Modified:
Dec 19, 2016 11:12 am US/Eastern
Created:
May 17, 2007 12:10 pm GMT-4
by
admin
JumpURL: