1

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.

user710818
  • 23,228
  • 58
  • 149
  • 207

1 Answers1

1

If you are using vim (enhanced vi editor) you can do it right in the editor:

  1. switch to command mode : PRESS ESC
  2. 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