源文件编码:gbk
源文件名称模式:*.ftl.gbk
目标文件编码:utf8
目标文件名称模式:*.ftl
脚本:to_utf8.sh
#!/bin/sh
for srcfile in *.gbk;
do
dstfile=${srcfile/.gbk/}
if [ "$srcfile" -nt "$dstfile" ]; then
echo convert $srcfile to $dstfile ...
iconv -f gbk -t utf8 $srcfile >$dstfile
fi
done
执行示例:
当有新的文件或新的修改时
[root@s170 ws1_hndy_wapmoban]# ./to_utf8.sh
convert sitemap.ftl.gbk to sitemap.ftl ...
[root@s170 ws1_hndy_wapmoban]#
当没有修改时
[root@s170 ws1_hndy_wapmoban]# ./to_utf8.sh
[root@s170 ws1_hndy_wapmoban]#
本文链接:http://codingstandards.iteye.com/blog/1563470
本文介绍了一个用于将GBK编码的文件批量转换为UTF-8编码的Shell脚本。该脚本能够智能地处理文件名,并仅对已更新的文件进行转换,避免不必要的重复工作。
461

被折叠的 条评论
为什么被折叠?



