I have developed a small script to remove the Control M characters that get embedded when we move any file from Windows to Unix. For some reason, its not working in all scenarios. Some times I still see the ^M not being removed. Is there anything missing in the script:
cd ${inputDir}
lCountFixed=0
lCountAll=$(find . | wc -l)
doclist=$(find .)
for v in $doclist
do
echo "\n Scan file:"$v
lc=$(od -t x1 $v | grep '0d 0a' | wc -l)
if [ $lc -ne 0 ];
then
lCountFixed=`expr ${lCountFixed} + 1`
docname=${v}
cat ${docname} | col -b > tep
mv tep ${docname}
chmod 755 ${docname}
echo " Fixed file:"$v
fi
done
Any inputs please why the 'col -b' does not work all times?