#/bin/bash
fpath="/home/chenyu/Desktop/linux/dabian/shell/1.txt"
#fdir="/home/chenyu/Desktop/linux/dabian/shell/back"
fdir="./back"
fexe="./file.sh"
#判斷是否為文件
if [ -e $path ];
then
echo "file "${fpath}" exist";
else
echo "file "${fpath}" dose not exist"
fi
#判斷是否為目錄
if [ -d $fdir ];
then
echo "dictionary "${fdir}" exist";
else
echo "dictionary "${fdir}" dose not exist"
fi
#判斷是否為可執行文件
if [ -x $fexe ];
then
echo ${fexe}" can exec"
else
echo ${fexe}" can not exec"
fi
3 運行結果
file /home/chenyu/Desktop/linux/dabian/shell/1.txt exist
dictionary ./back exist
./file.sh can exec