用file命令查看编码格式过滤掉utf-8文件。See bellow:
#!/bin/bash
echo "bakuping ..."
cp $1 $1-bakup -r
echo "converting..."
downdir() {
for file in `ls $1`
do
if [ -d $1/$file ]
then
downdir $1"/"$file
else
#echo -e $1/$file
file $1/$file|grep -i "$1/$file: ISO-8859 text" && echo "Convert to utf-8" && iconv -f gbk -t utf-8 $1/$file -o $1/$file
fi
done
}
downdir $1
echo done