Thursday, March 22, 2012

UNIX TOOLS - Operator conditional in Shell Script

For Mathematics, use following operator in Shell Script

Mathematical Operator in  Shell Script MeaningNormal Arithmetical/ Mathematical StatementsBut in Shell
   For test statement with if commandFor [ expr ] statement with if command
-eqis equal to5 == 6if test 5 -eq 6if [ 5 -eq 6 ]
-ne is not equal to5 != 6if test 5 -ne 6if [ 5 -ne 6 ]
-lt is less than5 < 6if test 5 -lt 6if [ 5 -lt 6 ]
-le is less than or equal to5 <= 6if test 5 -le 6if [ 5 -le 6 ]
-gt is greater than5 > 6if test 5 -gt 6if [ 5 -gt 6 ]
-ge is greater than or equal to5 >= 6if test 5 -ge 6if [ 5 -ge 6 ]
NOTE: == is equal, != is not equal.

No comments:

Post a Comment