Home ›
Remove ^M from the end of all lines in a file that some fool edited with a Windows programRemove ^M from the end of all lines in a file that some fool edited with a Windows program
Submitted by Benjamin Melançon on April 4, 2010 - 4:54pm
Where foo is the file that has the control Ms:
cat foo | col -b > foo2; mv foo2 foo
For instance, to take a likely Drupal example:
cat page.tpl.php | col -b > page.tpl.php.fixed; mv page.tpl.php.fixed page.tpl.php
Alternately, to do a bunch of files at once, use the *nix find
command and the more convenient one-command dos2unix line ending changer via the tofrodos package.
Install the prerequisites first if you need to:
sudo apt-get install tofrodos
Then run the command, this one runs only for CSS files:
find . -type f -name "*.css" -exec dos2unix "{}" \;
Searched words:
remove ^M
vi Ubuntu
control M
Comments
Post new comment