内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用
#!/bin/bash ICONVBIN='/usr/bin/iconv' # path to iconv binary if [ $# -lt 3 ] then echo "$0 dir from_charset to_charset" exit fi for f in $1/* do if test -f $f then echo -e "\nConverting $f" /bin/mv $f $f.old $ICONVBIN -f $2 -t $3 $f.old > $f else echo -e "\nSkipping $f - not a regular file"; fi done
或者尝试:
sudo convert/dir_iconv.sh convert/books CURRENT_ENCODING utf8