Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ephraimduncan/c8cf4bc1d9c551c755635123d93b0f82 to your computer and use it in GitHub Desktop.
Save ephraimduncan/c8cf4bc1d9c551c755635123d93b0f82 to your computer and use it in GitHub Desktop.
Comparison Operators in Bash
Operator Purpose For DataType
= Equal to operation string
== Equal to operation string
!= is not equal to string
< is less than in ASCII alphabetical order string
> is greater than in ASCII alphabetical order string
-z if a string is empty (or null) string
-n if a string is not empty (or not null) string
-eq is equal to number
-ne is not equal to number
-lt is less than number
-le is less than or equal to number
-gt is greater than number
-ge is greater than or equal to number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment