Bash scripting for real work: safe scripts that automate

Write Bash scripts that quote correctly, fail safely, parse arguments, clean up after themselves and pass ShellCheck, with tests and scheduling

7 ratings 2,190 students Sample

Created by Hana Novak

  • Updated September 2026
  • English
  • Intermediate

What you will learn

  • Quote variables and expansions correctly in every situation
  • Handle errors with exit codes, strict mode and traps
  • Use arrays, functions and parameter expansion to keep scripts clear
  • Parse options with getopts and print helpful usage messages
  • Schedule scripts safely with cron and systemd timers
  • Lint, format and test scripts with ShellCheck, shfmt and Bats

Course content

6 sections, 24 lessons, 3h 46m total

Foundations of reliable scripts 5 lessons · 45 min
  • Video: Anatomy of a good script Preview 9 min
  • Article: Quoting: the rule that prevents most bugs Preview 11 min
  • Article: Exit codes, conditions and tests 10 min
  • Article: Strict mode and its surprises 10 min
  • Quiz: Check your understanding 5 min
Variables, arrays and functions 4 lessons · 40 min
  • Video: Parameter expansion tricks you will use 10 min
  • Video: Indexed and associative arrays 11 min
  • Article: Functions, scope and return values 10 min
  • Video: Reading input and files line by line 9 min
Arguments, options and user interface 3 lessons · 29 min
  • Video: Parsing options with getopts 11 min
  • Article: Dry runs and confirmation prompts 9 min
  • Video: Logging with timestamps and levels 9 min
Files, cleanup and concurrency 4 lessons · 37 min
  • Video: Temporary files with mktemp and trap 10 min
  • Article: Signals and graceful interruption 9 min
  • Video: Preventing overlapping runs with flock 9 min
  • Video: Atomic writes and safe file updates 9 min
Scheduling and running unattended 3 lessons · 29 min
  • Article: Cron the right way 10 min
  • Video: systemd timers as a cron alternative 11 min
  • Video: Making scripts observable 8 min
Quality and real projects 5 lessons · 46 min
  • Article: ShellCheck and shfmt in your workflow 9 min
  • Video: Testing scripts with Bats 11 min
  • Video: Project: backup with retention 12 min
  • Article: When to stop using Bash 8 min
  • Quiz: Final check 6 min

Requirements

  • Comfortable with basic Linux commands and pipes
  • Access to a Linux shell with Bash 5, or WSL 2

Description

Most Bash scripts start as a few commands pasted into a file. They work until the day a file name contains a space, a command fails halfway, or the script runs from cron with a different environment. This course teaches you to write scripts that survive those days.

What you will learn

  • Quoting rules that prevent the most common and most dangerous bugs
  • Strict mode, exit codes and error handling, including where strict mode surprises people
  • Variables, arrays, parameter expansion and functions
  • Parsing options and arguments with getopts and clear usage messages
  • Temporary files, traps and cleanup
  • Logging, locking and running safely from cron and systemd timers
  • Linting with ShellCheck, formatting with shfmt and testing with Bats

How the course works

Every concept is shown with a small script you run and then break on purpose. We collect the good habits into a template you can start every new script from. In the last section we write three complete tools you can adapt: a backup script with retention, a log cleanup job and a deployment helper.

We target Bash 5 on Linux. macOS ships an old Bash 3.2 by default and uses zsh as the login shell, so I show how to install a current Bash with Homebrew if you practise on a Mac.

When not to use Bash

We also discuss honestly when a script has outgrown Bash and should be rewritten in Python or Go.

Who this course is for

  • System administrators automating routine tasks
  • Developers who maintain build and deploy scripts
  • DevOps engineers who want CI scripts that fail loudly and safely

Instructor

Hana Novak

Linux automation engineer teaching Bash scripting and Ansible for people who manage real servers

  • 4.4 instructor rating
  • 13 reviews
  • 3,840 students
  • 2 courses
  • Sample

I look after fleets of Linux servers and I automate anything I have to do twice. Bash covers the small jobs and Ansible covers everything that needs to be repeatable across many machines.

My courses are practical and a little strict. You will learn to write scripts that fail safely, quote variables properly and log what they did, and playbooks that can run a second time without breaking anything.

I build every lab on virtual machines you can create for free, and I explain each command line flag the first time it appears. If you have ever copied a script from the internet and hoped it worked, my courses are for you.

View profile

Student reviews

4.4 7 ratings
5 star 57%
4 star 29%
3 star 14%
2 star 0%
1 star 0%
Moses N. Sep 25, 2026
Sample

Cron and timers lesson solved a mystery

Our cron job failed silently because of PATH. Fixed within minutes after this lesson.

Sebastian K. Sep 13, 2026
Sample

Strict mode surprises were eye opening

I had relied on set -e inside functions called from if. The lesson showed exactly why it did not work.

Yasmin A. Aug 11, 2026
Sample

ShellCheck changed how I write Bash

Running ShellCheck on our old scripts found dozens of quoting bugs. The quoting lesson explained every one.

Priya S. Jul 19, 2026
Sample

Template script is so useful

I start every new script from the template built in the course. Fewer bugs and much clearer code.

Gabriel T. Jun 20, 2026
Sample

Great practical projects

The backup project with retention and locking is now running on our servers. Bats setup took a little effort.

Agnieszka L. Apr 18, 2026
Sample

Clear and well structured

Short lessons with examples you can break. I liked the honest advice about when to switch to Python.

Julien M. Jan 31, 2026
Sample

Good, assumes Linux comfort

Solid content, but you should be comfortable with the shell before starting.

$29.99 Enroll now
SampleSample catalog: the instructors, courses, reviews and stats on this site are demo content.