Pipe it through 'col -b' col outfile perl -npe 's/\015//g' < infile.cgi > outfile.cgi perl -i -p -e 's/\r$//' your files fromdos dos2unix tr -d "\r" < dosfile > outfile Emacs "replace-regexp". you can enter the control character ^M by typing ^Q^M. When asked what to replace it with, just hit return. The vim editor has a neat feature: if you edit the file and ":set ff=unix" the file will be saved without CR caracters, and if you ":set ff=dos" it will save the file with CR characters. Otherwise, most vi version can do ":%s/^V $//" as the equivalent of the emacs command above.