Thursday, October 15, 2009

Removing ^M (Ctrl +M) characters

Time to time we have to delete ^M charaters in *nix from a files, here is a simple script which will do it fast.

#!/usr/bin/ksh
# To remove ctrl+M character from txt file in solaris
# Date: 2009-02-06
# ctrl_m.sh

if [ -f $1 ]
then
tr -d '\15' < $1 >newname
mv newname $1
fi

Script first remove the ^M characters and then move the file to same filename.

No comments:

Post a Comment