🐚 Shell Conditionals Lesson
📝 Basics
if [ condition ]; then ... fi
— Basic if statement
else
— Executes if condition is false
elif [ condition ]
— Else if for multiple checks
Use
-eq
,
-ne
,
-gt
,
-lt
,
-ge
,
-le
for number comparisons
Use
=
or
!=
for strings
💻 Try It Yourself
#!/bin/bash num=5 if [ $num -gt 10 ]; then echo "Number is greater than 10" elif [ $num -eq 5 ]; then echo "Number is exactly 5" else echo "Number is less than 10" fi
▶️ Run Simulation
Output will appear here...