How to remove ^M from files

When you transfered a file from Windows to Linux, you have ^ M characters that appear. This is due to the end line characters on Windows (\ r \ n) which are differents from Linux (\ n). There is some tips to remove them.

  • On vi, in command mode
:%s/[ctrl+v][ctrl+M]//
  • On emacs
M-%
  • From the shell, install tofrodos (on Debian):
$ dos2unix file.txt

$ unix2dos file.txt

The second command do the opposite.

0 Responses to “How to remove ^M from files”


  • No Comments

Leave a Reply