IF TEST Bash Simple Program
#!/bin/bash
a=10
b=11
if [ "$a" -eq "$b" ]
then
echo " a and b is equal"
else
echo " a and b is not equal"
fi
if [ "$a" -ne "$b" ]
then
echo " a and b is not equal"
else
echo " a and b is equal"
fi
if [ -n "$c" ]
then
echo "c is not null"
else
echo "c is not declared, is null"
fi
c=""
if [ -z "$c" ]
then
echo "c is empty"
else
echo "c has text"
fi
c="test"
if [ -z "$c" ]
then
echo "c is empty"
else
echo "c has text"
fi
Result
a and b is not equal
a and b is not equal
c is not declared, is null
c is empty
c has text