if else statement in bash code example
Example 1: else if statement bash syntax
#!/bin/bash
read -p "Enter your marks: " marks
if [ $marks -ge 80 ]
then
echo "Very Good"
elif [ $marks -ge 50 ]
then
echo "Good"
elif [ $marks -ge 33 ]
then
echo "Just Satisfactory"
else
echo "Not OK"
fi
Example 2: if else statement example in shell script
if [ ... ]
then
# if-code
else
# else-code
fi
Example 3: ash if statment
if [ "$USER" == "Adam" ]
then
echo "User is Adam"
else
echo "User is not Adam"
fi