Remove ^M from text file
You can use sed
:
sed 's/^M// filename > newfilename
If you wish to use awk
then do:
awk '{sub(/^M/,"")}1' filename > newfilename
To enter ^M
, type CTRL-V
, then CTRL-M
. That is, hold down the CTRL key
then press V
and M
in succession.
Update
As suggested by @glenn jackman in comments, it is easy to use \r
then to get ^M
col < input > output
Or:
vim "+set ff=unix" "+saveas output" "+q" input