Chinaunix首页 | 论坛 | 博客
  • 博客访问: 417492
  • 博文数量: 168
  • 博客积分: 320
  • 博客等级: 二等列兵
  • 技术积分: 955
  • 用 户 组: 普通用户
  • 注册时间: 2012-06-21 08:40
个人简介

知足却不乏追求

文章分类

全部博文(168)

文章存档

2017年(1)

2016年(6)

2015年(36)

2014年(5)

2013年(6)

2012年(114)

分类:

2012-12-05 08:05:37

[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

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