C# - how to remove ctrl M characters when transferring files from windows to unix using Tectia? C# - how to remove ctrl M characters when transferring files from windows to unix using Tectia? unix unix

C# - how to remove ctrl M characters when transferring files from windows to unix using Tectia?


How I was able to remove it in vi editor:

  • After :%s/ then press ctrl+V then ctrl+M. This will give you ^M
  • Then //g (will look like: :%s/^M ) press Enter should get all removed.

Good luck!


If you just need to remove the ^M characters (not replace them with \n):

sed -i -e 's/\r//g' yourfile.txt

If you want to replace them with \n:

sed -i -e 's/\r/\n/g' yourfile.txt


You can install and use dos2unix. After Installation just run:

>dos2unix yourfile.txt