創建一個腳本文件(名字任意),直接複製下面代碼:
#/bin/bash
ExcludeOtherPath()
{
tarfile=0
file $1 | grep compressed
if [ $? == 0 ];then
tarfile=1
fi
rpmfile=0
file $1 | grep RPM
if [ $? == 0 ];then
rpmfile=1
fi
if [ $tarfile == 1 ] || [ $rpmfile == 1 ];then
return 1
fi
}
for path in `find $1`
do
ExcludeOtherPath $path
file=$?
if [ -f $path ] && [ $file != 1 ] ;then
cat $path | tr -d "\r" > $path"_1"
mv $path"_1" $path
chmod a+x $path
fi
done
使用方式
sh 腳本名稱 目錄路徑
注意
轉換之前強烈建議創建一份備份文件!!!
1、以上代碼僅支持CRLF轉LF;
2、以上代碼僅會跳過tar包和rpm包,其他種類壓縮包會造成損壞。