Monday, January 12, 2009

How to remove windows carriage return (^M) on Mac

I don't want to install dos2unix via port and I know it's just a matter of search and replace those ^M chars.

Here are a couple of command that should do the job of removing those trailing ^M (carriage return) chars.

perl -pi -e's/\r//g' filename
sed -e's/^M//g' filename > newfile

To type ^M in Terminal do Ctrl+V then Ctrl+M.

No comments: