Remove ^M Character From Unix File Using VI
-
By Jing Hong on April 27, 2010 | No Comments
Looking for command to remove special character using VI edit in Unix operating system?
Special character like ^M in your shell script file will eventually caused problem as you run the script.
Interpreter “/usr/bin/ksh” not found is one of the example error you will got if there’s special character ^M in your scripting file.
Remove Unix Special Character Command
$ ./script.sh interpreter "/usr/bin/ksh" not found ksh: ./script.sh: not found
Open your file in VI editor and type :%s/(CTRL-V)(CTRL-M)//g to fix this.
The ^M will be removed once you hit the Enter button.
$ vi script.sh :%s/(CTRL-V)(CTRL-M)//g
^v is a CONTROL-V character and ^m is a CONTROL-M character and :%s is a basic search and replace command in vi with g at the end will replace all matching globally.
PreviousNext» Wordpress Security Hardening Using .htaccess
Leave a Comment
