Check That Will Ya?
Condition expressions are normally used with the builtin '[ ]' and 'test' commands. In truth, '[ ]' is short hand for the 'test' command. You've probably seen it in shell scripts:
if [ some condition ]; then
do something
fi
Here are the expressions:
-a file True if file exists
-b file True if file exists and is blk special file
-c file True if file exists and is char special file
-d file True if file exists and is directory
-e file True if file exists
-f file True if file exists and is regular file
-g file True if file exists and is set-gid
-k file True if file exists and set sticky bit
-p file True if file exists and is a pipe
-r file True if file exists and is readable
-s file True if file exists size > than zero
-t file True if file exists and open to a terminal
-u file True if file exists and is set-uid
-w file True if file exists and is writable
-x file True if file exists and is executable
-0 file True if file exists and owned by user-id
-G file True if file exists and owned by group-id
-L file True if file exists and is a symbolic link
-S file True if file exists and is a socket
-N file True if file exists and modified since read

Comments :
0 comments to “Bash Test Files”
Post a Comment