test - check file types and compare values
test [expr] test {--help,--version}
This manual page documents the GNU version of test. Note that most shells have a built-in command by the same name and with similar functionality. test returns a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr. Expressions may be unary or binary. Unary expressions are often used to examine the status of a file. There are string operators and numeric comparison operators as well. -b file True if file exists and is block special. -c file True if file exists and is character special. -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. -k file True if file has its ``sticky'' bit set. -L file True if file exists and is a symbolic link. -p file True if file exists and is a named pipe. -r file True if file exists and is readable. -s file True if file exists and has a size greater than zero. -S file True if file exists and is a socket. -t [fd] True if fd is opened on a terminal. If fd is omit- ted, it defaults to 1 (standard output). -u file True if file exists and its set-user-id bit is set. -w file True if file exists and is writable. -x file True if file exists and is executable. -O file -G file True if file exists and is owned by the effective group id. file1 -nt file2 True if file1 is newer (according to modification date) than file2. file1 -ot file2 True if file1 is older than file2. file1 -ef file2 True if file1 and file2 have the same device and inode numbers. -z string True if the length of string is zero. -n string string True if the length of string is non-zero. string1 = string2 True if the strings are equal. string1 != string2 True if the strings are not equal. ! expr True if expr is false. expr1 -a expr2 True if both expr1 and expr2 are true. expr1 -o expr2 True if either expr1 or expr2 is true. arg1 OP arg2 OP is one of -eq, -ne, -lt, -le, -gt, or -ge. These arithmetic binary operators return true if arg1 is equal, not-equal, less-than, less-than-or- equal, greater-than, or greater-than-or-equal than arg2, respectively. arg1 and arg2 may be positive integers, negative integers, or the special expres- sion -l string, which evaluates to the length of string. OPTIONS When GNU test is invoked with exactly one argument, the following options are recognized: --help Print a usage message on standard output and exit successfully. --version Print version information on standard output then exit successfully.