O'Reilly logo
live online training icon Live Online training

Introduction to the Bash Shell

Master the most commonly-used technology in tech

Ian Miell

Bash is a technology used on a daily basis by almost all software engineers working on a Mac or Linux machine. Often taken for granted, Bash scripting is useful for everything from writing Jenkins pipelines to managing Kubernetes clusters.

Unfortunately Bash is often not taken seriously as a tool, which leads to confusion and misuse which can baffle users. This course will walk through the fundamentals, which will mean you will never be confused or lost in a Bash script or one-liner again, and be able to write useful Bash of your own devising.

What you'll learn-and how you can apply it

By the end of this live, hands-on, online course, you’ll understand:

  • Bash fundamentals such as variables and functions
  • Bash scripting with concepts such as exit codes, looping, tests and substitutions
  • Advanced topics like signals and traps, and debugging techniques

And you’ll be able to:

  • Write your own Bash scripts
  • Impress your colleagues with your Bash skills
  • Confidently work with any bash thrown at you

This training course is for you because...

  • You’re a software engineer
  • You work with the Linux command line
  • You want to become a senior engineer

Prerequisites

  • Beginner-level familiarity with the command line
  • Access to a Bash shell via any standard Terminal program

Recommended preparation:

Please write down some notes on the following, to be shared (optionally) at the start of the course:

  • Tasks you’d like to solve using Bash
  • Bash features or applications of particular interest

Recommended follow-up:

About your instructor

  • Ian Miell has over twenty years' experience in IT, writing, running, architecting, and maintaining software for some of the world's busiest systems.

    He has written the book 'Docker in Practice' (published by Manning), 'Learn Bash the Hard Way' (published on Leanpub), as well as various training courses and videos.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Bash Basics I (50-55 minutes)

  • Discussion: 5 minutes
  • What do you want to do with bash (see recommended preparation above)?
  • Presentation: What is bash, basics part I (globbing, variables) - 15 minutes
  • Exercise: 10 minutes
  • Globbing challenge
  • Shell variable research
  • Presentation: Basics, part II (pipes and redirects) - 10 minutes
  • Exercise: 10 minutes
  • Pipes and redirect challenges
  • Discussion: 5 minutes
  • Recap material
  • Break (5 minutes)

Bash Basics II (50-55 minutes)

  • Discussion: 5 minutes
  • What is a programming language? Is bash a programming language?
  • Presentation: Exit codes, tests, loops, functions - 25 minutes
  • Exercise: 10 minutes
  • Write function that works over files in a folder
  • Presentation: Command and file substitution - 15 minutes
  • Discussion: 5 minutes
  • Recap material
  • Break (5 minutes)

Scripting Bash (50-55 minutes)

  • Presentation: Scripts and Startup, Shell Options, Debugging - 20 minutes
  • Exercise: 10 minutes
  • Examine your own startup
  • Change startup to add options, see what happens
  • Presentation: Subshells, IFS - 10 minutes
  • Exercise: 10 minutes
  • Write script to deal with sets of folders with spaces in filenames
  • Discussion: 5 minutes
  • Recap material
  • Break (5 minutes)

Advanced Bash (50-55 minutes)

  • Presentation: Trapping and signals - 15 minutes
  • Exercise: 10 minutes
  • Script you can’t escape?
  • Presentation: String manipulation, autocomplete - 15 minutes
  • Discussion: 10 minutes
  • Walk-through of ‘cheapci’ script