AND
[prabhucloudxlab@cxln4 ~]$ cat>hello.sh
#! bin/bash
# And Operators : Both conditions should be true
#! bin/bash
# And Operators : Both conditions should be true
age=10
if [ "$age" -gt 18 ] && [ "$age" -lt 40 ]
then
echo " age is correct"
else
echo " age is not correct"
fi
# Another Syntaxes :
# if [[ "$age" -gt 18 && "$age" -lt 40 ]]
# if [ "$age" -gt 18 -a "$age" -lt 40 ]
# if [[ "$age" -gt 18 && "$age" -lt 40 ]]
# if [ "$age" -gt 18 -a "$age" -lt 40 ]
[prabhucloudxlab@cxln4 ~]$ sh hello.sh
age is not correct
# Note:
if [ "$age" -gt 18 ] && [ "$age" -lt 15 ] --->> 1st condition is false, 2nd condition is true
# age is not correct
# age is not correct
if [ "$age" -gt 9 ] && [ "$age" -lt 15 ] --->> both conditions is true
# age is correct
#=======================================================
#=======================================================
OR
[prabhucloudxlab@cxln4 ~]$ cat>hello.sh
#! bin/bash
# OR Operators : One condition is true
age=10
if [ "$age" -gt 18 ] || [ "$age" -lt 40 ]
then
echo " age is correct"
else
echo " age is not correct"
fi
# Another Syntaxes :
# if [[ "$age" -gt 18 || "$age" -lt 40 ]]
# if [ "$age" -gt 18 -o "$age" -lt 40 ]
# if [[ "$age" -gt 18 || "$age" -lt 40 ]]
# if [ "$age" -gt 18 -o "$age" -lt 40 ]
[prabhucloudxlab@cxln4 ~]$ sh hello.sh
age is correct