🔀 Bash Conditions
Bash uses
if
,
elif
, and
else
to run code based on conditions.
📖 Example:
num=10 if [ $num -gt 5 ] then echo "Greater than 5" else echo "5 or less" fi
▶️ Try It Yourself
num=7 if [ $num -gt 5 ] then echo "Greater than 5" else echo "5 or less" fi
▶️ Run Simulation
Output will appear here...
💡 Tip: Always put spaces between brackets and your values:
[ $num -gt 5 ]