Using vi editor:
:%s/^M//g
Using col command:
cat filename | col -b > newfilename
Using sed command:
sed 's/^M//g' filename > newfilename
Using dos2unix comand:
dos2unix filename newfilename
Examples:
volcano@volcano-laptop:~/shellscript/ctrl$ cat -v jsk
hi^M
jsk^M
volcano@volcano-laptop:~/shellscript/ctrl$ cat jsk | col -b > jsk.new
volcano@volcano-laptop:~/shellscript/ctrl$ cat -v jsk.new
hi
jsk
volcano@volcano-laptop:~/shellscript/ctrl$ sed 's/^M//g' jsk > jsk.new2
volcano@volcano-laptop:~/shellscript/ctrl$ cat -v jsk.new2
hi
jsk
Note: Hold the control key and then press v and m to get the control-m character
165 comments:
Post a Comment