Skip to main content
Programming Languages

Bash Tutorial with Examples.

Bash scripting tutorial with runnable examples: Linux shell scripting for automation, CI/CD pipelines, DevOps workflows and server administration.

Beginner

Start here — no prior experience needed

9 lessons
bash beginner
5 min read

Understand what Bash is, how it differs from a terminal and a shell, and why it is the backbone of DevOps, CI and automation work.

bash beginner
5 min read

Install Bash on Linux, macOS and Windows WSL, write and run your first script, and fix chmod, /bin/sh vs bash, and CRLF line-ending errors.

bash beginner
5 min read

Master variable assignment, quoting rules, environment variables, export, and special variables like $0, $1, $#, $@, and $$.

bash beginner
5 min read

Learn how Bash handles strings, integers, indexed and associative arrays, namerefs and case attributes, with real output for every example.

bash beginner
5 min read

Learn arithmetic operators with $(( )), floating-point math with bc, string comparison, and the difference between test, [ ], and [[ ]].

bash beginner
5 min read

Master Bash if/elif/else, case, for, while and until loops, break and continue, with real output and the pipe-subshell and unmatched-glob traps.

bash beginner
5 min read

Learn how to define functions, use local variables, handle return codes, pass arguments, and build reusable script libraries.

bash beginner
5 min read

Bash file operations: file tests, reading files safely, cp, mv, safe rm, find, stat, symlinks and atomic writes, each shown with its real output.

bash beginner
5 min read

Learn read, echo vs printf, stdin/stdout/stderr, redirection operators, tee, and pipes for building robust Bash pipelines.

Intermediate

For developers with core concepts down

11 lessons
bash intermediate
5 min read

Master Bash parameter expansion: substrings, prefix and suffix stripping, find-and-replace, case conversion, trimming, splitting and heredocs.

bash intermediate
5 min read

Work with Bash indexed and associative arrays: slicing, quoting with [@] vs [*], mapfile, filtering, sorting, and passing arrays to functions.

bash intermediate
5 min read

Process text in Bash pipelines with grep, sed, awk, cut, sort, uniq, tr, wc and column, using real log and CSV examples and their real output.

bash intermediate
5 min read

Run background jobs, manage processes with jobs/fg/bg, send signals with kill, use trap for cleanup, and understand subshells.

bash intermediate
5 min read

Write robust scripts with set -euo pipefail, trap ERR, exit codes, meaningful error messages, and safe cleanup patterns.

bash intermediate
5 min read

Use the Bash =~ operator, BASH_REMATCH capture groups, grep -E and -P, and sed -E for validation and parsing, with the pitfalls that fail silently.

bash intermediate
5 min read

Bash networking with curl, jq, nc, /dev/tcp and rsync: status and exit codes, safe JSON, port checks, wait-for-port, and SSH heredoc quoting.

bash intermediate
5 min read

Inspect a Linux system from Bash with uname, df, du, free, ps, pgrep, ss, lsof and systemctl, and parse their output reliably in scripts.

bash intermediate
5 min read

Crontab syntax, cron expressions, at for one-time jobs, systemd timers and logging cron output, with real cron and systemd runs.

bash intermediate
5 min read

Write secure Bash scripts — safe temp files with mktemp, avoiding command injection, handling secrets, and setting file permissions.

bash intermediate
5 min read

Learn production-ready patterns — argument parsing with getopts, usage functions, loading config files, and script locking.

Advanced

Production-grade patterns for experienced engineers

2 lessons

Also part of Bash

Taught in other topics. Each link opens the lesson in its home topic.

2 lessons