Created
March 29, 2022 01:29
-
-
Save inclyc/c0f8d39153e800e2c2c36ba12aa581c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 遍历文件夹中的所有文件,将字符集从GB18030转换为UTF | |
# 参数: | |
# $1:源文件夹 | |
# $2:目标文件夹 | |
# 获取文件夹中的所有文件: | |
FILES=`find $1 -type f` | |
# 遍历所有文件,转换字符集,转换行尾序列: | |
for FILE in $FILES | |
do | |
cp $FILE $FILE.tmp | |
iconv -f GB18030 -t UTF-8 $FILE.tmp > $2/$FILE | |
sed -i 's/\r$//' $2/$FILE | |
rm $FILE.tmp | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment