[ cmd ] POSIX test (same as 'test cmd') [[ cmd ]] BASH test Flags: (return true if) ! negates previous test -n string is non-zero -z string length is zero -v variable is set -R variable is set and a name reference -e file exists -f file is regular file -d file is directory -h/L file is symlink -b file is block device -c file is character device -p file is pipe -S file is socket -s file is not zero size -t returns true if tty -r file has read permission -w file has write permission -x file has execute permission -g group-id flag set -u user-id flag set -k sticky bit set -O you are owner of file -G file has same group-id as you -N file modified since last read -nt file is newer than -ot file is older than -ef files are hardlinks to the same file -o optname is enabled Strings: == strings are equal = strings are equal ([[ ]] only) != strings are not equal < string1 sorts before string 2 > string1 sorts after string 2 Numerical: (integers only) -eq equals -ne not equals -lt less than -le less than or equal -gt greater than -ge greater than or equal