All programming languages have the if & else conditions and they’re different in syntax according to each programming languages. In Bash, it’s really different and even a small space can cause syntax errors. So, you have to be careful while writing Bash code.
In this post, I’ll give you many examples on how to use if and else conditions in Bash.
if, else
a="AC"
if [ $a = "AC" ]; then
echo "yes"
else
echo "no"
fi
Notice the usage of then. It’s necessary to let Bash know that if the condition returns TRUE, do the code below it.
... [READ MORE]