Remove ^M characters from xhtml file

Simon Gray simong at desktop-guardian.com
Mon Dec 1 06:54:03 PST 2003


> I've downloaded a couple of .xhtml files and they have ^M characters
> all through it. I tried the col -b < name > newname command on these
> files but when I do that it erases the whole document. Any ideas?


handy little shell script i found a while ago which does exactly what you're
after


#!/bin/sh
# rmc.sh
# remove ^M characters
#
# slee 021116
# http://freebsd.mu

if [ $# -eq 1 ]
then
tr -d '\015' < $1 > $1.tmp.$$
mv -f $1.tmp.$$ $1
else
echo "Usage: $0 filename"
fi


Just place within /usr/local/bin and do 'chmod +x /usr/local/bin/rmc.sh'
then just do 'rmc.sh file' as and when you need.

HTH

Simon



More information about the freebsd-questions mailing list