From the course: Linux: Files and Permissions

Unlock the full course today

Join today to access over 25,200 courses taught by industry experts.

Matching with brace expansion

Matching with brace expansion - Linux Tutorial

From the course: Linux: Files and Permissions

Matching with brace expansion

- [Instructor] We can match most files using standard globs but sometimes it gets a bit messy because we can only match one character at a time. For instance, a character set with jm in it followed by pg will match both JPG and MPG. That's simple enough. However, if you want to match JPG and PNG, it's gets more complex and less precise. We can use two character sets, one with jp and the other was pn followed by a lone g. This will match JPG and PNG, but also JNG and PPG, which is not as precise as we'd like. The Bash shell provides another technology called brace expansion that is not technically globbing but we can use it to our advantage. Globbing is referred to as pattern matching. When we use a glob, the shell looks for files that match the pattern in the file system. Brace expansion is pattern creation because it expands to create a pattern as if we'd typed it in. For instance, echo space left curly brace 1..10…

Contents