(OK) digui-dir-del-M.sh——递归


digui-dir-del-M.sh


#!/bin/sh

eachd() {
        for chkfile in $1/*
        do
                if [[ -f "$chkfile" ]]
                then
                    result=`file $chkfile |awk '{print $2}'`
                    if [ "$result" == "ASCII" ]
                    then
                        sed 's/\r//g' $chkfile >temp.c
                        mv temp.c $chkfile
                        #echo $chkfile #>> result.txt
                    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


posted @ 2016-04-17 21:46  张同光  阅读(90)  评论(0编辑  收藏  举报