Basic Decision Making with if-then-else in Bash
📖 Scenario: You are writing a simple script to check if a number is positive, negative, or zero. This is like checking the weather and deciding what to wear: if it's hot, wear shorts; if cold, wear a jacket; else wear something in between.
🎯 Goal: Build a bash script that uses if-then-else statements to print whether a number is positive, negative, or zero.
📋 What You'll Learn
Create a variable
number with the value 5Create a variable
zero with the value 0Use
if, elif, and else to check if number is greater than, less than, or equal to zeroPrint exactly
Positive, Negative, or Zero based on the check💡 Why This Matters
🌍 Real World
Scripts often need to make decisions based on input values, like checking if a file exists or if a user is logged in.
💼 Career
Understanding if-then-else logic is essential for automating tasks, writing installation scripts, and managing system operations.
Progress0 / 4 steps