#!/bin/bash # This is program will check you file name,which sys has or not,end print types. #2019/07/19 FSQ First release echo -e "input file name:" ...
#!/bin/bash
# This is program will check you file name,which sys has or not,end print types.
#2019/07/19 FSQ
First release
echo -e "input file name:" filename
read filename
test -z $filename && echo "please input a file name" && exit 0 #test -z 檢查輸入是否為空
test ! -e $filename && echo" $filename is not exsit" && exit 0 # test -e 檢查輸入的文件是否存在
test -d $filename && filetype="regulare file" #檢查文件的是否是目錄
test -f $filename && filetype="directory" #檢查文件是否常規文件
test -r $filename && perm="readable" #檢查文件的執行狀態 是否可讀
test -w $filename && perm="$perm writeable" #檢查文件的執行狀態 是否可寫
test -x $filename && perm="$perm execute#檢查文件是否 可執行
echo "The file name : $filename is a $filetype" #輸出文件的類型
echo "And the permissions are :$perm" #輸出文件的許可權