Example of a simple If loop
#!/bin/bash
a="abcd"
b="abd"
c="ee"
d="ee"
if [ $a = $b ] [ $c = $d ]
then
echo "equal"
echo "We are good"
else
echo "NOT equal"
fi
Example of a if loop with elif
#!/bin/bash
a="Fremont"
if [ $a = "Fremont" ]
then
echo "North California";
elif [ $a = "Los Angeles" ]
then
echo "South California"
else
echo "Out of california"
fi
No comments:
Post a Comment