#!/bin/bash #History: #2019/07/23 Fsq #This Program will check Permissions on dir PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/ ...
#!/bin/bash
#History:
#2019/07/23 Fsq
#This Program will check Permissions on dir
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
read -p "please input your dir:" dir
if [ "$dir" == "" -o ! -d "$dir" ];then #檢查目錄是否存在
echo "This $dir is not exsit in system"
exit 1
fi
filelist=$(ls $dir) #列出該目錄下的所有文件名
for filename in $filelist
do
perm=""
test -r "$dir/$filelist" && perm="$perm readable"
test -w "$dir/$filelist" && perm="$perm writable"
test -x "$dir/$filename" && perm="$perm executable"
echo "The file $dir/$filename's permission is $perm"
done