Press "Enter" to skip to content

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:

Vinish Kapoor

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. foxinfotech.in is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *