Bash test operators
09 Oct 2013A cheat sheet for bash test operators:
| Math Operators | Meaning |
|---|---|
| -eq | equal to |
| -ne | not equal to |
| -lt | less than |
| -le | less than or equal to |
| -gt | greater than |
| -ge | greater than or equal to |
| String Operators | |
| = | equal to |
| != | not equal to |
| -n | not null and exists |
| -z | null and exists |
| File Operators | |
| -s | not empty |
| -f | is file and not a directory |
| -d | is directory and not a file |
| -w | is writeable |
| -r | is read-only |
| -x | is executable |
| Logical Operators | |
| ! | not |
| -a | and |
| -o | or |