Bash Shell Test Operators Cheat Sheet

In Bash, when writing shell scripts then we need to use test operators to compare integer values, strings, and logical tests and file tests, etc. So here I am sharing the list of all bash shell operators in text and in picture format, which is downloadable.

Bash Shell Test Operators Cheat Sheet

Integer ComparisonsFunction
-gtGreater than
-ltLess than
-geGreater than or equal to
-leLess than or equal to
-eqEqual to
-neNot equal to
String ComparisonsFunctions
-zTest for empty string
=Test for equality of strings
!=Test for inequality of strings
Logical OperatorsFunction
-aLogical AND
-oLogical OR
!Logical NOT
File Test OperatorsFunction
-fFile exists and is a regular file
-sFile is not empty
-rFile is readable
-wFile can be written to and modified
-xFile is executable
-dFilename is a directory name

Download the Bash Shell Test Operators Cheat Sheet in Picture format:Bash Shell Test Operators Cheat Sheet

See also:

Leave a Comment