课程: Linux CentOS 7: Shells and Processes

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Pattern matching with globs

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…

内容