Also exists as a built-in in most shells.
expression and, if its value is
true, returns a zero exit status; otherwise, returns a nonzero exit status. In shell scripts, you can use the alternate form
]. This command is generally used with conditional constructs in shell programs.
The syntax for all of these options is test
option file. If the specified file doesn't exist, the testers return
false. Otherwise, they test the file as specified in the option description.
Is the file block special?
Is the file character special?
Is the file a directory?
Does the file exist?
Is the file a regular file?
Does the file have the set-group-ID bit set?
Is the file owned by the process's effective GID?
Does the file have the sticky bit set?
Is the file a symbolic link?
Is the string of nonzero length?
Is the file owned by the process's effective UID?
Is the file a named pipe?
Is the file readable by the current user?
Is the file nonempty?
Is the file a socket?
Is the file associated with
(or 1, which is standard output, by default) connected to a terminal?
Does the file have the set-user-ID bit set?
Is the file writable by the current user?
Is the file executable?
The syntax for file comparisons
file1 option file2. A string by itself, without options, returns
true if it's at least one character long.