We can remove ^M by below methods
1st Method - Using sed command
Type below command:
sed -e "s/^M//" filename > newfilename
Note :- To enter ^M, type CTRL-V, then CTRL-M.
2nd Method - Using vi Editor
Open the file in vi editor
vi filename
Inside vi [in ESC mode] type below command-
:%s/^M//g
then [Press Enter Key ]
Note :- To enter ^M, type CTRL-V, then CTRL-M.
then save the file by below command
:wq