批量修改文本文件编码GB18030为UTF-8

来源:互联网 发布:蹦极的感觉 知乎 编辑:程序博客网 时间:2024/06/11 00:29
[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

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(370) | 评论(0) | 转发(0) |
0

上一篇:QQ设计第1-5步

下一篇:Andriod被排出Linux内核的原因

相关热门文章
  • A sample .exrc file for vi e...
  • IBM System p5 服务器 HACMP ...
  • 游标的特征
  • DB2 9 应用开发(733 考试)认...
  • busybox的httpd使用CGI脚本(Bu...
  • linux dhcp peizhi roc
  • 关于Unix文件的软链接
  • 求教这个命令什么意思,我是新...
  • sed -e "/grep/d" 是什么意思...
  • 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
原创粉丝点击