Bash Scripting for Developers
Master Bash scripting from the ground up — variables, control flow, functions, and process automation. By the end, you build a fully automated deployment and monitoring toolkit used in real DevOps workflows.
Course Content
6 modules · 30 lessonsShell Fundamentals
Understand how the shell works and write your first executable Bash scripts.
What is Bash and why developers use it
shell vs terminal, Bash vs sh vs zsh, Unix philosophy, shebang line, script execution model, PATH variable
Bash variables and quoting rules explained
variable assignment, dollar-sign expansion, single vs double quotes, unset variables, readonly, local scope, word splitting
How Bash exit codes and error handling work
exit codes, $? variable, set -e, set -u, set -o pipefail, trap ERR, command success vs failure convention
Bash input and output redirection fundamentals
stdin stdout stderr, file descriptors 0 1 2, redirect operators, /dev/null, tee command, heredoc, pipe operator
Command substitution and arithmetic in Bash
command substitution $(), backtick syntax, arithmetic expansion $(( )), let builtin, bc for floats, expr limitations, integer vs float handling
Control Flow and Logic
Write conditional logic, loops, and case statements to control script behavior dynamically.
Bash if statements and test conditions
if elif else syntax, test command, [ ] vs [[ ]], string comparison, numeric comparison operators, file test operators, compound conditions
Bash for loops and while loops with examples
C-style for loop, for-in loop, while loop, until loop, break and continue, loop over files, loop over command output, IFS variable
Bash case statement for multi-branch logic
case syntax, pattern matching, wildcard patterns, | alternation in case, ;; vs ;& vs ;;& terminators, case vs if-elif chain, argument parsing with case
Bash arrays and how to iterate them correctly
indexed arrays, array declaration, array access, array length, array slicing, associative arrays, iterate with for, append to array, unset array element
Bash select menu and user input handling
select statement, read command, read -p prompt, read -s silent input, read -t timeout, PS3 variable, validating user input, reading from stdin vs arguments
Functions and Script Architecture
Write reusable, maintainable Bash functions and organize scripts for real-world production use.
How to write and call Bash functions
function declaration syntax, calling functions, return values, return vs exit, function arguments $1 $2, local variables, function scope, overriding built-ins
Bash local variables and scope explained
global vs local scope, local keyword, dynamic scoping in Bash, function side effects, nameref variables, subshell scope, environment vs shell variables, export
Bash script structure and sourcing files
script organization pattern, sourcing with dot operator, source vs execute, library scripts, guard against re-sourcing, __dirname equivalent, relative paths in scripts
How to write a Bash logging library
log levels, color output with tput, stderr vs stdout logging, log to file and terminal simultaneously, timestamps in logs, log verbosity flag, disabling color in CI
Bash argument parsing with getopts
getopts vs getopt, short option syntax, option with argument, OPTARG OPTIND, error handling in getopts, required vs optional arguments, help flag pattern, shift after getopts
Text Processing and File Operations
Manipulate text, parse structured files, and automate file system operations using core Unix tools.
grep, sed, and awk — which tool to use when
grep pattern matching, sed stream editing, awk field processing, when to use each tool, extended regex, in-place editing with sed, awk field separator, combining tools in pipelines
Bash string manipulation without external tools
parameter expansion, substring extraction, string length, find and replace in variables, prefix and suffix stripping, default values, case conversion, string splitting with IFS
Parsing CSV and JSON in Bash scripts
IFS-based CSV parsing, limitations of Bash CSV parsing, jq for JSON, jq filters and select, extracting values from API responses, iterating JSON arrays with jq, jq as a dependency
Bash file and directory operations at scale
find command, find with exec, xargs for bulk operations, mktemp, file locking with flock, recursive operations, handling special filenames, stat command, file permissions with chmod
Bash regex matching and string validation
=~ operator in [[ ]], BASH_REMATCH array, ERE syntax, validating email IP UUID date formats, regex vs glob, anchoring patterns, character classes, negation
Process Management and Automation
Control background jobs, signals, and processes to build reliable automation and scheduling scripts.
Bash background jobs and job control explained
background with &, jobs command, wait builtin, fg and bg, disown, nohup, job IDs vs PIDs, parallel execution pattern, collecting exit codes from background jobs
Bash signals and trap for graceful shutdown
Unix signals, SIGTERM SIGINT SIGKILL SIGHUP, trap syntax, trap with signal names, cleanup on exit, forwarding signals to child processes, kill command, signal numbers
Scheduling Bash scripts with cron and systemd timers
cron syntax, crontab fields, crontab -e, environment in cron, systemd timer units, OnCalendar syntax, cron vs systemd comparison, logging cron jobs, run-parts, anacron
How to monitor and manage Bash script processes
ps and pgrep, kill and pkill, pidfile pattern, wait with timeout, process substitution, /proc filesystem, lsof for open files, monitoring script health with while loop
Bash parallel processing with xargs and GNU parallel
xargs -P for parallelism, GNU parallel basics, parallel vs xargs, controlling job count, parallel with progress, collecting output, handling failures in parallel, rate limiting
DevOps Scripting Patterns
Apply Bash scripting to real DevOps scenarios: deployment automation, secret management, and infrastructure tooling.
Bash script testing and debugging techniques
set -x tracing, bash -n syntax check, shellcheck static analysis, set -v verbose, PS4 variable, bats testing framework, assert functions, testing functions in isolation, debugging subshells
Managing secrets and environment variables in Bash
never hardcode secrets, environment variable injection, .env file loading, printenv and env auditing, secret masking in logs, vault and AWS SSM integration patterns, secure temporary files, variable sanitization
Building a CI/CD deployment script in Bash
deployment script structure, pre-deploy checks, blue-green deployment pattern, rollback mechanism, health check loop, deployment lock, notifications via curl webhook, idempotency
Bash scripts for Docker and Kubernetes automation
docker CLI in scripts, waiting for containers, kubectl in scripts, checking pod status, applying manifests, waiting for rollout, namespace operations, image tagging patterns, docker compose in CI
Building a self-contained Bash CLI tool
CLI tool structure, subcommand dispatch, help generation, version flag, --completion support, color detection, install and uninstall targets, Makefile integration, distributing Bash scripts
