Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting rid of special characters. (^M)

Status
Not open for further replies.

wolves

Programmer
Jan 26, 2001
130
US
I copied over a file from c:\ to unix box, but now I have some ' ^M ' at the end of my lines.

How can I get rid of these?

Thanks in advance
 
man dos2unix
or the sed way:
sed 's!.$!!' /path/to/dosfile >unixfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
faq80-1911

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Just wanted to add a little blurb about why this happens. In a windows text editor (and, from what I have noticed, the Gnome desktop text editor alike), a carriage return is defined by a \r.....in a Unix text editor, a \n defines this. What the dos2unix converter does, is reads in the dos like carriage returns and converts them to unix carriage returns. If need be, there are times when you transfer a unix text file to a DOS platform, and you can run the "unix2dos" converter also. Hope this helps.

___________________________________
[morse]--... ...--[/morse], Eric.
 
nawlej, in Dos/Windows end of line is CrLf, in Unix Lf.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
nawlej, in Dos/Windows end of line is CrLf, in Unix Lf.

Im aware. You are correct.....I basically said the same thing, except I was speaking in terms of programming, and how the converter handles such a thing. Thank you for your clarification though.....Sometimes I forget everyone is not fluent in programming concepts.

___________________________________
[morse]--... ...--[/morse], Eric.
 
Thanks. got it fixed. And thanks for the link comtec17, that was great. Something to keep.
 
A simple way to remove ^M

Log into your unix machine and VI the specific file!

Then type:

:g/s/^m///

It will state that ( 'X' number of ^M have been removed )

Then save the file and you're done!

Hope this helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top