Tuesday, January 17, 2012

Arithmetic Comparison Operators used in Shell Script


Different Arithmetic Comparison operators used in shell script are

1. -lt: It has same meaning as <.

$ cat > arth.sh
#!/bin/bash
num1=1;
num2=2;

if [ $num1 -lt $num2 ] ; then
echo "num1 is less then num2"
else
echo "num2 is less than num1"
fi
Output

$ ./arth.sh
num1 is less then num2
2. -gt : It has same meaning as  >.

$ cat > arth.sh
#!/bin/bash
num1=1;
num2=2;

if [ $num2 -gt $num1 ] ;

0 comments:

Post a Comment