[bash] Condition Tests
Test |
Comparison |
---|---|
-lt | |
-le | |
-eq | |
-ge | |
-gt | |
-ne |
Operator |
True if... |
---|---|
-a file | |
-d file | |
-e file | |
-f file |
file exists and is a regular file (i.e., not a directory or other special type of file) |
-r file | |
-s file | |
-w file | |
-x file |
You have execute permission on file, or directory search permission if it is a directory |
-N file | |
-O file | |
-G file |
file's group ID matches yours (or one of yours, if you are in multiple groups) |
file1 -nt file2 |
file1 is newer than file2 [6] |
file1 -ot file2 |
[6] Specifically, the -nt and -ot operators compare modification times of two files.
Operator |
True if... |
---|---|
str1 = str2[4] | |
str1 != str2 | |
str1 < str2 | |
str1 > str2 | |
-n str1 | |
-z str1 |