How to remove ^M at the end of each line in Linux
When working with files that have been transferred from Windows to Linux ^M characters may show at the end of each line, making the file useless. Here’s how to fix that..
It has been said that you can avoid this by making sure to use the ASCII mode when you transfer files to Linux. If you are unable to avoid it, you can use the following to get rid of the ^M at the end of each line:
Open the file using “VI”
Now do the following:
:%s/.$// <enter> this will remove the last character at the end of each line!
:wq! to write and exit the editor!
All set..!
If this post helped you out, help me out keeping this site alive and visit some of my sponsors on the left or right.. Thanks..!
TAGS: remove, ^M, Linux, VI,
Posted: February 25th, 2010 under Linux.
Comments: none