Week-2 | Day-8: Shell Scripting Basics (Variables & Loops)
🐚 What is Shell Scripting?
- A Shell Script is a text file containing commands that can be executed by the shell (like
bash
, sh
, zsh
).
- Helps automate repetitive tasks (file backups, system monitoring, deployments, etc.).
🧩 Variables
Variables store data that can be reused later in the script.
Syntax:
variable_name=value
⚠️ No spaces before or after = in Bash.
Example:
#!/bin/bash
name="Harideep"
echo "Hello, $name! Welcome to CloudInSteps."
Reading input from user:
echo "Enter your favorite tool:"
read tool
echo "You like $tool!"
Types of variables:
- System Variables: predefined (e.g.,
$USER
, $HOME
, $PWD
)
- User-defined Variables: created by the user
Example:
echo "Current user: $USER"
echo "Home directory: $HOME"