You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operator Description Example
-eq Is Equal To [ 100 -eq 100 ]
-ne Is Not Equal To [ 100 -ne 200 ]
-gt Is Greater Than [ 200 -gt 100 ]
-ge Is Greater Than Or Equal To [ 100 -ge 100 ]
-lt Is Less Than [ 100 -lt 200 ]
-le Is Less Than Or Equal To [ 100 -le 100 ]
== Is Equal To (( 100 == 100 ))
!= Is Not Equal To (( 100 != 200 ))
< Is Less Than (( 100 < 200 ))
<= Is Less Than Or Equal To (( 100 <= 100 ))
> Is Greater Than (( 200 > 100 ))
>= Is Greater Than Or Equal To (( 200 >= 100 ))
String Comparison
Operator Description Example
= or == Is Equal To [ abc == abc ]
!= Is Not Equal To [ abc != def ]
> Is Greater Than (ASCII) [ def > abc ]
>= Is Greater Than Or Equal To [ def >= def ]
< Is Less Than [ abc < def ]
<= Is Less Than Or Equal To [ abc <= def ]
-n Is Not Null [ -n abc ]
-z Is Null (Zero Length String) [ -z "" ]
File Tests
Operator Description Example
-d Directory [ -d /tmp/abc ]
-e Exists (also -a) [ -e /tmp/abc ]
-f Regular file [ -f /tmp/abc ]
-h Symbolic link (also -L) [ -h /tmp/abc ]
-p Named pipe [ -p /tmp/abc ]
-r Readable by you [ -r /tmp/abc ]
-s Not empty [ -s /tmp/abc ]
-S Socket [ -S /tmp/abc ]
-w Writable by you [ -w /tmp/abc ]
-N Modified since last read [ -N /tmp/abc ]
File Comparison
Operator Description Example
-nt Newer Than [ /tmp/a -nt /tmp/b ]
-ot Older Than [ /tmp/a -ot /tmp/b ]
-ef Hard Link To [ /tmp/a -ef /tmp/b ]