linux简单脚本2

来源:互联网 发布:java中的md5怎么解密 编辑:程序博客网 时间:2024/05/16 18:18
#!/bin/shchangemod (){    if [ -d $filepath ]; then        cd $filepath                for var in `ls -tr`        do            changefilemod $var                    done                return 0    else        if [ -f $filepath ]; then            changefilemod $filepath               return $?           else               return -1        fi    fi}changefilemod(){    filename="$1"    if [  -n $filename -a $filename != "chmod.sh" ]; then        chmod $mode $filename            return 0        else            return -1    fi}handelfilepath(){    if [ -z $filepath ] || [ $filepath = "null" ]; then        filepath=`pwd`    fi}handelmode(){    if [ -z $mode ]; then        mode="744"    fi}checkparams(){    paramnumber=$1    if [ $paramnumber -eq 1 ];then        echo "your params is error you can user this shell like this ./chmod.sh or ./chmod null 774 "        return -1    else        return 0    fi}##################################################################main#################################################################filepath=$1mode=$2checkparams $# if [ $? -ne 0 ];then        exit 1 fihandelfilepathhandelmodechangemodresultCode=$?if [ $resultCode -eq "0" ]; then    echo "change mode ok"else    echo "change mode fail....."fi    


 

0 0
原创粉丝点击