Linux中去除 ^M
转自网络
^M == \r\n
在AIX下windows的回车(\r\n)被识别成^M+回车
方法1:
dos2unix urfile.txt
方法2:
tr -d '\015' ufile >newfile
方法3:
sed -i 's/\r//' filename
aix下取出"^M"字符
#!/bin/sh
filename=$1
for name in `ls $filename`
do
if [ "$name" != "format_file.sh" ];then
tr -s '\015' '\012' <$name >"${name}_bak"
mv "${name}_bak" "$name"
fi
done
exit 0