Master shell scripting fundamentals on Mac and Linux terminals
14views
005:09
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
š **Creating and Running Scripts**
- Understanding shell scripts and the shebang line (#!/bin/bash)
- Making scripts executable with chmod +x
- Running scripts with ./script.sh or bash script.sh
- Creating and using variables (NAME='John', echo $NAME)
- Command substitution with $(command) and backticks
- Storing command output in variables
- Understanding variable expansion and quoting
š **Conditional Statements**
- Basic if statement syntax: if [ condition ]; then ... fi
- File tests: -f (file exists), -d (directory exists), -e (exists)
- String comparisons: == (equal), != (not equal)
- Numeric comparisons: -eq, -ne, -lt, -gt, -le, -ge
- If-else statements for alternative branches
- Elif (else-if) for multiple conditions
- Logical operators: && (AND), || (OR)
- Testing conditions with the test command
- Practical examples for file and directory checks
š **Loops: for and while**
- For loop syntax: for variable in list; do ... done
- Iterating over lists of words
- Brace expansion: {1..10} for sequences
- C-style for loop: for ((i=1; i=10; i++))
- While loop: while [ condition ]; do ... done
- Using break to exit loops early
- Using continue to skip iterations
- Looping through files with wildcards (*.sh)
- Incrementing counters in loops
- Practical examples for automation
**Commands Covered:**
- #!/bin/bash - Shebang line
- chmod +x script.sh - Make script executable
- ./script.sh - Run executable script
- bash script.sh - Run script with bash
- NAME='value' - Create variable
- $NAME - Use variable
- $(command) - Command substitution
- `command` - Command substitution (older syntax)
- if [ condition ]; then ... fi - If statement
- if [ -f file ]; then ... - Check if file exists
- if [ -d dir ]; then ... - Check if directory exists
- [ "$VAR" == "value" ] - String comparison
- [ $NUM -lt 10 ] - Numeric comparison
- for i in {1..5}; do ... done - For loop with range
- for ((i=1; i=5; i++)); do ... done - C-style for loop
- while [ condition ]; do ... done - While loop
- break - Exit loop early
- continue - Skip to next iteration
**Perfect for:**
- Mac and Linux terminal users ready to automate tasks
- Developers learning shell scripting fundamentals
- System administrators creating automation scripts
- Anyone wanting to learn bash scripting basics
- Users looking to create custom commands
- Beginners starting their shell scripting journey
Back to tutorialsOpen in YouTube
Duration
5:09
Published
December 27, 2025
Added to Codegiz
March 15, 2026