Answers for "bash if greater than"

3

bash if greater than

if (( a > b )); then
    ...
fi
#Use above example or below one:
if [ "$a" -gt "$b" ]; then
    ...
fi
Posted by: Guest on February-18-2021
1

greater than in script

-eq
is equal to

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

-ne
is not equal to

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

-gt
is greater than

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

-ge
is greater than or equal to

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

-lt
is less than

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

-le
is less than or equal to

if [ "$a" -le "$b" ]
Posted by: Guest on November-08-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

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language