1. 程式人生 > >迴圈刪除程式碼中^M的shell指令碼

迴圈刪除程式碼中^M的shell指令碼

#! /bin/bash
#echo “start……”
#define a function to read all the files in the folder
function readfile(){
for file in ls $1
do
if [ -d 1"/"1"/"file ]
then
readfile 1"/"1"/"file
else
touch $1"/“temp.txt
sed ‘s/^M//g’ 1"/"

1"/"file>$1”/“temp.txt
mv $1”/“temp.txt 1"/"1"/"file
#echo 1"/"1"/"file
#echo $1”/"
#echo basename $file
fi
done
}
folder="./aaa"
readfile $folder