Shell/Bash: bash if greater than Example


Shell/Bash Example: This is the "bash if greater than" Example. compiled from many sources on the internet by

bash if greater than

if (( a > b )); then
#Use above example or below one:
if [ "$a" -gt "$b" ]; then

greater than in script

is equal to

if [ "$a" -eq "$b" ]

is not equal to

if [ "$a" -ne "$b" ]

is greater than

if [ "$a" -gt "$b" ]

is greater than or equal to

if [ "$a" -ge "$b" ]

is less than

if [ "$a" -lt "$b" ]

is less than or equal to

if [ "$a" -le "$b" ]

bash if larger than

# In bash, you should do your check in arithmetic context:

if (( a > b )); then

# For POSIX shells that don't support (()), you can use -lt and -gt.

if [ "$a" -gt "$b" ]; then

* Summary: This "bash if greater than" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!