From the course: Linux CentOS 7: Shells and Processes

Unlock the full course today

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

Pattern matching with globs

Pattern matching with globs - Linux Tutorial

From the course: Linux CentOS 7: Shells and Processes

Start my 1-month free trial

Pattern matching with globs

- [Narrator] One of the reasons that manipulating files on the command line can be faster and more efficient than the GUI is pattern matching. In Bash, pattern matching is called file globbing, and all commands can use it. File globs allow us to match patterns. For instance, if we wanted to list config files, we could match files ending in .conf by using an asterisk. So we'd type in ls /etc/*.conf An asterisk matches any type of character and any number of them. So file.* would match any word that starts with file, has a dot in it, and is followed by any number of characters. A question mark matches any type of character but only one of them. So file?.txt would match filea.txt and file1.txt. If you want to match two characters, you're going to have to include two question marks. We could match a range or a list of characters with a set using square brackets. Each set matches exactly one character, but that one character can be any of the items in the range or list. By placing a hyphen…

Contents