Hello,
I am Aaditya Purani ,If statements (and, closely related, case statements) allow us to make decisions in our Bash scripts. They allow us to decide whether or not to run a piece of code based upon conditions that we may set. If statements, allow us to make much more complex scripts which may solve larger tasks.
Sometimes we want to perform a certain set of actions if a statemen is true, and another set of actions if it is false. We can accommodate this with the else mechanism.
Code:
#!/bin/bash
echo “Hey dude. Which color you like”
read color
if [ $color = “red” ]
then
echo “Correct one man”
elif [ $color = “green” ]
then
echo “Pretty nice guess”
else
echo “Sorry duh”
fi