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
  • 21,911
  • 55
  • 143
  • 199

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
  • 20,234
  • 3
  • 30
  • 56