Script _ whether a file or directory exists

! # / bin / bash
IF [$ # -eq 0]; the then
   echo "do not enter any file or directory, the script exits" && Exit
fi
IF [-f $ 1]; the then
   echo "the file exists, as follows:"
   LS - Exit. 1 && $ L
the else
   echo "Sorry, that file is"
Fi
IF [-d $. 1]; the then
   echo "the directory exists, as follows:"
   LS -ld $ 2 && Exit
the else
   echo "Sorry, not the directory"
Fi

Guess you like

Origin www.cnblogs.com/liusingbon/p/11140470.html