Test Expression Operators

,
Operator Description
-a file Test if file exists
-b file Test if file exists and is a block special file
-c file Test if file exists and is a character special file
-d file Test if file exists and is a directory
-e file Test if file exists
-f file Test if file exists and is a regular file
-g file Test if file exists and has the setgid bit set
-h file Test if file exists and is a symbolic link
-k file Test if file exists and has the sticky bit set
-L file Test if file exists and is a symbolic link
-O file Test if file exists and is owned by the current user
-o file Test if file is older than the current file
-p file Test if file exists and is a named pipe (FIFO)
-r file Test if file exists and is readable
-s file Test if file exists and has a size greater than zero
-S file Test if file exists and is a socket
-u file Test if file exists and has the setuid bit set
-w file Test if file exists and is writable
-x file Test if file exists and is executable
file1 -nt file2 Test if file1 is newer than file2 using modification timestamp
file1 -ot file2 Test if file 1 is older than file 2 using modification timestamp
file1 -ef file2 Test if file1 and file2 are associated by a link
-n string Test if the length of the string is nonzero bytes
-z string Test if the length of the string is zero bytes
string1 = string2 Test if string1 is equal to string2
string1 != string2 Test if string1 is not equal to string2
string Test if string is not empty
int1 -eq int2 Test if int1 is equal to int2
int1 -ne int2 Test if int1 is not equal to int2
int1 -lt int2 Test if int1 is less than int2
int1 -le int2 Test if int1 is less than or equal to int2
int1 -gt int2 Test if int1 is greater than int2
int1 -ge int2 Test if int1 is greater than or equal to int2
! condition Test if the condition is false
condition1 -a condition2 Test if both condition1 and condition2 are true
condition1 -o condition2 Test if either condition1 or condition2 is true
(( expression )) Test if the arithmetic expression evaluates to a nonzero value
[ -t n ] Test if file descriptor n is open and associated with a terminal
[[ expression ]] Test if the expression evaluates to true
(( var++ )) Test if var is incremented