批量修改文本文件编码GB18030为UTF-8
2017-03-01 09:39
1001 查看
[root@localhost Desktop]# ./digui-gb18030-utf8.sh experiment
digui-gb18030-utf8.sh 文件内容如下:
#!/bin/sh
eachd() {
for chkfile in $1/*
do
if [[ -f "$chkfile" ]]
then
result=`file $chkfile |awk '{print $2}'`
if [ "$result" == "PHP" ]
then
#do
iconv -f GB18030 -t UTF-8 "$chkfile" > tmp 2>/dev/null
if [ $? -eq 0 ];then
mv tmp "$chkfile"
else
echo "$chkfile没有被转换"
rm tmp
fi
#done
fi
fi
if [[ -d $chkfile ]]
then
eachd $chkfile
fi
done
}
#eachd "."
if test -d $1
then
eachd $1
elif test -f $1
then
echo "you input a file but not a directory,pls reinput and try again"
exit 1
else
echo "the Directory isn't exist which you input,pls input a new one!!"
exit 1
fi
digui-gb18030-utf8.sh 文件内容如下:
#!/bin/sh
eachd() {
for chkfile in $1/*
do
if [[ -f "$chkfile" ]]
then
result=`file $chkfile |awk '{print $2}'`
if [ "$result" == "PHP" ]
then
#do
iconv -f GB18030 -t UTF-8 "$chkfile" > tmp 2>/dev/null
if [ $? -eq 0 ];then
mv tmp "$chkfile"
else
echo "$chkfile没有被转换"
rm tmp
fi
#done
fi
fi
if [[ -d $chkfile ]]
then
eachd $chkfile
fi
done
}
#eachd "."
if test -d $1
then
eachd $1
elif test -f $1
then
echo "you input a file but not a directory,pls reinput and try again"
exit 1
else
echo "the Directory isn't exist which you input,pls input a new one!!"
exit 1
fi
相关文章推荐
- 批量修改文本文件编码GB18030为UTF-8
- 批量修改文本文件编码GB18030为UTF-8
- [原创]使用java批量修改文件编码(ANSI-->UTF-8)
- 批量修改文件的编码格式至UTF-8
- 批量修改java文件编码(GBK->UTF-8),带备份和恢复功能
- 批量修改文件的编码方式
- 批量修改文件的编码方式
- 在解决乱码问题是,如何修改文本文件的编码类型。
- 使用eclipse插件批量将Java源代码文件的编码从GBK(或其他编码)转为UTF-8
- myeclipse 如何统一修改全部的java、jsp、js 等文件的编码 例如修改为utf-8
- Eclipse:批量将Java源代码文件的编码从GBK转为UTF-8
- Shell应用:批量将文件编码由gbk转utf-8
- 批量修改文件编码
- eclipse文本编码格式修改为UTF-8 Result.java乱码
- Myeclipse批量修改整个工程的编码格式为UTF-8
- myeclipse 如何统一修改全部的java、jsp、js 等文件的编码 例如修改为utf-8
- 修改右键菜单中新建txt文本文件的默认编码
- shell应用:批量将文件编码由gbk转utf-8
- linux shell 批量更改文件编码格式 gbk到utf-8
- 批量将Java源代码文件的编码从GBK转为UTF-8