Answers for "bash compare numbers"

0

number compare in bash

#!/bin/bash
# Script to do numeric comparisons
var1=10
var2=20
if [ $var2 -gt $var1 ]
    then
        echo "$var2 is greater than $var1"
fi
# Second comparison
If [ $var1 -gt 30]
    then
        echo "$var is greater than 30"
    else
        echo "$var1 is less than 30"
fi
Posted by: Guest on August-01-2020
0

bash if larger than

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

if (( a > b )); then
    ...
fi

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

if [ "$a" -gt "$b" ]; then
    ...
fi
Posted by: Guest on September-23-2020
0

bash compare numbers

bash if greater thanShell/Bash By Me (Armandres) on Feb 18 2021 DonateDeleteEdit
if (( a > b )); then
    ...
fi
#Use above example or below one:
if [ "$a" -gt "$b" ]; then
    ...
fi
Posted by: Guest on February-18-2021

Code answers related to "bash compare numbers"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language