Variables and Patterns

In this chapter, we'll learn how to work with data and variables in Bash, and how to use them with pattern matching and shell glob syntax. While you can get a lot done by just piping existing commands together, we often need variables to get more fine-tuned behavior from scripts.

We'll cover:

  • Variable declarations and scope
  • Environment variables
  • String operations
  • Arithmetic expressions
  • Capturing program output in a variable
  • Matching filenames with glob patterns
  • Using arrays and associative arrays

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.