Carriage return and line feed (Re: [Techtalk] get rid of "^M" in a file)

maria maria at shadlen.org
Fri Jun 17 08:25:11 EST 2005


So the files I have been looking at were actually created on a mac, and 
seem to only have the ^M.  If I remove the ^M I just get one big glob of 
text.

I think I can figure something out using the solution Barb suggested, 
but I don't have a terminal right now, so I'll have to play with it later.

cheers,
maria

Mary wrote:
> 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
> _______________________________________________
> Techtalk mailing list
> Techtalk at linuxchix.org
> http://linuxchix.org/cgi-bin/mailman/listinfo/techtalk



More information about the Techtalk mailing list