Apache Awk Bash C cftp daemontools DHCP djbdns DNS Emacs Email ezmlm Fetchmail find GDB Hardware HTML HTTP Intro ISDN less Make Math mc mirrordir MySQL Peripherals Perl PHP3 pppd qmail Regexps Shell System Tables test To do Typical ucspi-tcp Versions Index TCP/IP slides
 

test evaluation

File type tests
-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.
-f file True if file exists and is a regular file.
-h file
or
-L file
True if file exists and is a symbolic link.
-p file True if file exists and is a named pipe.
-S file True if file exists and is a socket.
-T [fd] True if fd is opened on a terminal. If fd is omitted, it defaults to 1 (standard output).
Access permission tests
-g file True if file exists and is set-group-id.
-k file True if file has its ``sticky'' bit set.
-r file True if file exists and is readable.
-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 True if file exists and is owned by the effective user id.
-G file True if file exists and is owned by the effective group id.
File characteristics tests
-e file True if file exists
-s file True if file exists and has a size greater than zero.
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.
String tests
-z string True if the length of string is zero.
-n string
or
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.
Numeric tests
arg1 -eq arg2 Arithmetic binary operator that returns true iif arg1 is equal to arg2.
arg1 and arg2 may be positive integers, negative integers, or the special expression -l string, which evaluates to the length of string.
arg1 -ne arg2 Arithmetic binary operator that returns true iif arg1 is not-equal to arg2. See -eq for args.
arg1 -lt arg2 Arithmetic binary operator that returns true iif arg1 is less-than arg2. See -eq for args.
arg1 -le arg2 Arithmetic binary operator that returns true iif arg1 is less-than-or-equal than arg2. See -eq for args.
arg1 -gt arg2 Arithmetic binary operator that returns true iif arg1 is greater-than arg2. See -eq for args.
arg1 -ge arg2 Arithmetic binary operator that returns true iif arg1 is greater-than-or-equal than arg2. See -eq for args.
Connectives for test
! 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.
Last update: Wed, 2 Nov 2005 10:16:21 GMT