Wednesday, February 23, 2011

shell script - test

Check if the string is null
test -z $var && echo "The string is null" || echo "The string is not null"

Check if the var1 is greater than var2
test $var1 -gt $var2 && echo "var1 > var2" || echo "var1 < var2"

Check if value is 0
test $var -eq 0 && echo "var1 is 0" || echo "var1 is not 0"

No comments:

Post a Comment

You can leave any question here and I will make a response to you ASAP. :D