From the course: Linux CentOS 7: Shells and Processes

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 - Linux Tutorial

From the course: Linux CentOS 7: Shells and Processes

Start my 1-month free trial

Pattern matching with extended globs

- [Narrator] In addition to standard globs, bash allows us to use extended globs. This is an option that may be turned off in your version of Linux . Check to see if it's turned on, type in a terminal, shopt and hit enter. Look through the list and find extglob and ensure that's turned on. If it is not turned on you'll need to type in shopt -s extglob and hit enter. To make this persistent, you'll need to put it in your bash or C startup file. Extended globs give us more pattern matching power. They grant us the power to specify the number of occurrences to match, which is difficult to do with standard globs. They also allow grouping matches. Patterns can be more than one character. If we want to match three occurrences of ABC, we could. They also allow us to match one pattern or another. With extending globbing we can specify zero or one occurrences of a match. For instance, if we want to match zero or one occurrence of the letters ABC, we'd use file?(abc).txt for our pattern. To…

Contents