I have copied files from Windows. In Vi I see ^M that don't allow work. AFAIK this is problem with moving files from Windows to Linux. Does it possible to fix? Thanks.
Asked
Active
Viewed 1,373 times
1
-
Already answered here - http://stackoverflow.com/questions/1110678/m-at-the-end-of-every-line-in-vim – Yzmir Ramirez Nov 15 '11 at 07:00
1 Answers
1
If you are using vim (enhanced vi editor) you can do it right in the editor:
- switch to command mode : PRESS ESC
- type
:%s/\r//g
and voila :-)
Otherwise if you have the dos2unx
utility installed then you can use that to remove the ^M
(\r):
dos2unx infile.txt > outfile.txt
Otherwise you can use GNU sed which understands \r substitutions:
sed -e 's/\r$//' infile.txt > outfile.txt

Ahmed Masud
- 21,655
- 3
- 33
- 58