Carriage return and line feed (Re: [Techtalk] get rid of "^M" in a
file)
Mary
mary-linuxchix at puzzling.org
Thu Jun 16 18:40:24 EST 2005
On Thu, Jun 16, 2005, Maria McKinley wrote:
> I've never really thought about this before. How are carriage returns
> marked in linux text files? How would you substitute a ^M for a
> carriage return that more or cat would recognize?
There are two different characters involved. There is the "carriage
return" character (ASCII character 13) and the "line feed" character
(ASCII character 10).
MS-DOS format text files have lines ending in two characters: carriage
return followed by line feed. (Some internet protocols including HTTP
follow this convention too.) UNIX format text files have lines ending in
one character, the line feed character. (According to [1] carriage
return takes the cursor all the way to the left, and line feed takes it
down a line. Line feed has both functions on UNIX.)
So as it turns out you almost never have to substitute in a new
character for more/less/cat/UNIX-y utilities to recognise it: the line
feeds are already there. You just strip the carriage returns.
-Mary
[1] http://www.jimprice.com/jim-asc.htm
More information about the Techtalk
mailing list