Bash

Shell Scripting

·View all resources →

Bash Learning Roadmap

Bash is the standard shell and scripting language on Linux and macOS servers. Every DevOps pipeline, deployment script, and server automation task is written in Bash. It's not glamorous, but knowing Bash separates developers who can only write application code from those who can automate and operate entire systems. A force-multiplier skill for any backend or DevOps role.

Total time

4–6 weeks

Stages

4 stages

Job-ready at

Stage 3

Career paths

2 paths

1
2
3
4

Before you start — Prerequisites

✓
Linux command-line basics

Bash scripting builds directly on shell commands (ls, grep, find, pipes). You need those first.

1

Stage 1: Script Basics

Variables, arguments, and control flow

1–2 weeks

Topics to cover

#!/usr/bin/env bash and set -euo pipefailVariables: assignment, $VAR, ${VAR}Positional arguments: $1, $2, $@, $#if / elif / else with test conditionsComparison: -eq, -ne, -lt, -gt, -z, -nfor loops: over lists and rangeswhile loopsFunctions: define and callExit codes: $? and exit 0/1chmod +x and ./script.sh

Bold = especially important

Milestone

You write executable Bash scripts with variables, conditionals, loops, and functions — the core programming constructs in shell form.

Project to build

System info script

Script that accepts a --verbose flag, prints hostname, OS, uptime, disk usage, RAM, top 5 CPU processes — clean formatted output.

2

Stage 2: Text & File Processing

Manipulate files and process output

1–2 weeks

Topics to cover

Command substitution: $(command)String manipulation: ${#var}, ${var:0:5}, ${var/old/new}Arrays in Bash: declare -a, ${arr[@]}Reading files line by line: while IFS= readgrep, awk, sed in scriptsHeredocs: cat <<EOFProcess substitution: <(command)Here strings: <<< for single-line inputprintf for formatted outputtee: write to stdout and file simultaneously

Bold = especially important

Milestone

You process CSV files, parse log output, and manipulate strings in scripts without reaching for Python.

Project to build

Log analyser script

Read an nginx access log, count requests per IP, extract 4xx/5xx errors, write a summary report — pure Bash + grep/awk/sort.

3

Stage 3: Error Handling & Robustness

✓ Min. Job Ready

Scripts that work in production

1 week

Topics to cover

set -euo pipefail — the three essential flagstrap for cleanup on EXIT or ERRChecking command exit codes explicitlyLogging with timestamps and levelsDry-run mode with a flagIdempotent scripts (safe to run multiple times)Locking with flock to prevent concurrent runsRedirecting stderr: 2>&1, 2>/dev/nullTimeout with the timeout commandShellCheck: static analysis for Bash scripts

Bold = especially important

Milestone

Your scripts fail loudly on errors, clean up after themselves, and are safe to run in CI/CD pipelines without surprises.

Project to build

Robust backup script

Backup a directory with timestamp, trap for cleanup, logging with levels, dry-run flag, idempotent — ShellCheck clean.

4

Stage 4: Automation & DevOps Patterns

Real-world Bash for CI/CD and servers

1–2 weeks

Topics to cover

Environment variables and .env file sourcingCI/CD shell steps in GitHub ActionsDocker entrypoint scriptsDeployment scripts: pull, build, restartcron syntax and crontab -eSSH and remote command execution in scriptsParallel execution with & and waitcurl in scripts: API calls, health checksjq for parsing JSON in BashScript libraries: sourcing reusable functions

Bold = especially important

Milestone

You write deployment scripts, CI pipeline steps, and cron jobs that run reliably in production with proper environment handling.

Project to build

Zero-downtime deploy script

Pull latest code, run tests, build Docker image, swap containers, health check, rollback on failure — GitHub Actions compatible.

Career paths that use Bash

Frequently asked questions

Is Bash still relevant in the age of Python and Go?

Yes — Bash is the glue that holds systems together. CI/CD pipelines, Docker entrypoints, server setup scripts, cron jobs, and deployment hooks are almost always Bash. Python and Go are better for complex programs; Bash is better for composing existing Unix tools. Most DevOps engineers use both daily.

Should I learn Bash or Python for scripting?

Both — they solve different problems. Bash is best for: calling other programs, file manipulation, pipelines, system administration tasks (one-liners to 200 lines). Python is better for: complex logic, data processing, working with APIs, anything over 200 lines. Write Bash when you need to chain Unix tools; write Python when you need to think algorithmically.

Bash vs Zsh vs Fish — which should I learn?

Learn Bash. Zsh is compatible with Bash syntax and adds quality-of-life features (Oh My Zsh). Fish has a different syntax and is not POSIX-compatible. Scripts deployed to servers must be written in sh/bash — not zsh or fish. Your interactive shell can be zsh; your scripts should target bash.

What is a shebang and why does it matter?

The shebang (#!/bin/bash or #!/usr/bin/env bash) is the first line of a script that tells the OS which interpreter to use. Without it, the script runs in the current shell, which may be different on different systems. Always include a shebang. Use #!/usr/bin/env bash for portability across Linux and macOS.

How do I make a Bash script more robust?

Three flags change everything: set -e (exit on error), set -u (treat undefined variables as errors), set -o pipefail (catch errors in pipelines). Add these to the top of every non-trivial script. Combined as set -euo pipefail, they prevent the most common categories of silent Bash failures.

Ready to start learning?

Browse our curated Bash resources — every course, book, and video ranked by quality.

View Bash Resources →