2009-08-28

Unix Bash: test if file or directory exists

test -e test.txt


test -d dir




if [ -d dir ]



       -a file
              True if file exists.
       -b file
              True if file exists and is a block special file.
       -c file
              True if file exists and is a character special file.
       -d file
              True if file exists and
is a directory.
       -e file
              True if file exists.
       -f file
              True if file exists and is a regular file.









       -g file
              True if file exists and is set-group-id.

No comments: