basepath=`pwd`
touch $basepath/bakfile.list
for JAVA_FILE in $(find ./ -name "*.java")
do
if [ "$(file $JAVA_FILE | grep -v UTF-8)" != "" ] ;then
echo convert $JAVA_FILE
iconv -f GBK -t UTF-8 $JAVA_FILE > ${JAVA_FILE}.bak
echo "${JAVA_FILE}" >> $basepath/bakfile.list
fi
done
for f in `cat $basepath/bakfile.list` ;do echo $f; mv "$f.bak" $f ; done
原文:https://www.cnblogs.com/fastzhe/p/13514631.html