1.

How To Compare Numbers In Linux Shell Scripting?

Answer»

Test COMMAND is used to compare numbers in if-then statement.

Example is SHOWN below:

#! /bin/bash

X=10

y=20

if [ $x -gt $y ]

then

echo “x is GREATER than y”

else

echo “y is greater than x”

fi

Test command is used to compare numbers in if-then statement.

Example is shown below:

#! /bin/bash

x=10

y=20

if [ $x -gt $y ]

then

echo “x is greater than y”

else

echo “y is greater than x”

fi



Discussion

No Comment Found