[Techtalk] get rid of "^M" in a file

MMP - Barb Fox mmp_fox at bellsouth.net
Thu Jun 16 13:02:18 EST 2005


Although sometimes I'll use sed to do the substitution (as others have 
suggested), this particular case is probably even easier with the tr 
(translate) command.  It has a -d option to delete a particular character.

The ^M is really a carriage return - This is an ascii 015 or can be 
represented by the backslash token "\r".

cat dosfile.txt | tr -d '\015' > cleanfile.txt    OR

cat dosfile.txt | tr -d '\r' > cleanfile.txt

- Barb Fox
mmp_fox at bellsouth.net

At 08:03 PM 6/15/2005, you wrote:
>I have a file (.vimrc) which was in Windoze and now at
>the end of each line of the file I have a "^M" which
>is (obviously) generating lots of errors while
>executing vim.
>
>I want to get rid of all the "^M". I can hand-hack it
>but that sound inefficient. I wanted to use "flip -u"
>but the OS I am currently in doesn't have that.
>
>Is there anything else I can use to get rid of that?
>
>TIA.
>.noir
>
>
>
>___________________________________________________________
>How much free photo storage do you get? Store your holiday
>snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
>_______________________________________________
>Techtalk mailing list
>Techtalk at linuxchix.org
>http://linuxchix.org/cgi-bin/mailman/listinfo/techtalk



More information about the Techtalk mailing list