Chinaunix首页 | 论坛 | 博客
  • 博客访问: 25362
  • 博文数量: 9
  • 博客积分: 235
  • 博客等级: 二等列兵
  • 技术积分: 97
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-30 10:12
文章分类

全部博文(9)

文章存档

2012年(9)

我的朋友

分类: LINUX

2012-08-16 22:30:12

#!/bin/bash
# 查看目录下文件权限的脚本..
echo -e "Please enter the need to look at the state of the directory\n
For Example : \033[31m /etc \033[0m"
read DST
echo -e "\033[31;43m -------------OUTPUT-------------\033[0m"
if [ -d $DST ];then
for FILE in $DST/*
do
        FILEDIR=$(dirname $FILE)
        FILENAME=$(basename $FILE)
    ################ read ###################
    if [ -r $FILEDIR/$FILENAME ];then
        if [ -w $FILEDIR/$FILENAME ];then
            if [ -x $FILEDIR/$FILENAME ];then
                echo -e "$FILEDIR/$FILENAME permission is \033[31m -rwx \033[0m "
            else
                echo -e "$FILEDIR/$FILENAME permission is \033[31m -rw- \033[0m"   
            fi
        elif [ -x $FILEDIR/$FILENAME ];then
            echo -e "$FILEDIR/$FILENAME permission is \033[31m -r-x \033[0m"
        else
            echo -e "$FILEDIR/$FILENAME permission is \033[31m -r-- \033[0m"
        fi
    ############# write #######################
    elif [ -w $FILEDIR/$FILENAME ];then
        if [ -x $FILEDIR/$FILENAME ];then
            echo -e "$FILEDIR/$FILENAME permission is \033[31m --wx \033[0m "
        else
            echo -e "$FILEDIR/$FILENAME permission is \033[31m --w- \033[0m"
        fi
    ################# execute #######################
    elif [ -x $FILEDIR/$FILENAME ];then
        echo -e "$FILEDIR/$FILENAME permission is \033[31m ---x \033[0m"
    ################### OTHER ##################
    else
        echo -e "$FILEDIR/$FILENAME \033[31m No authority \033[0m"
    fi
done
  if [ "$?" == "0" ];then
    echo -e "\033[31;43m -------------ls- $DST--- OUTPUT-------------\033[0m"
      ls -l $DST
  fi
else
    echo "PLS input Effective directory"
fi

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