Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6553454
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: Python/Ruby

2011-11-14 17:30:33

[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

阅读(2036) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~