From the course: Bash Patterns and Regular Expressions

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Pattern matching with extended globs

Pattern matching with extended globs - Bash Tutorial

From the course: Bash Patterns and Regular Expressions

Start my 1-month free trial

Pattern matching with extended globs

- [Instructor] Now let's look at a real world example. In this scenario we created a great deal of backup files over the years and stored them in a directory. Be sure you're in your test files directory that we created in the last video, then type in ls. The format of these files are Archive or Backup followed by a dash then the year, dash, the month, dash, and the day followed by a combination of different archives and compressors. Let's build up an extended glob to match only these files. We'll start by matching the first part of the name which is either Archive or Backup which is then followed by a hyphen. Type in ls, space, at, left parentheses, Archive with a capital A, pipe, Backup with a capital B, right parentheses, hyphen. Then we'll use four character sets to match the year. Type in left square bracket, zero dash nine, right square bracket four time followed by a hyphen. Now we need two more character sets to match the month followed by a hyphen. Notice the month is always…

Contents