From the course: Bash Patterns and Regular Expressions
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Character sets - Bash Tutorial
From the course: Bash Patterns and Regular Expressions
Character sets
- [Instructor] Character sets are like a specialized question mark wildcard. They match exactly one character, but we get to specify the possible matches by providing a list. To create a character set, you use single square brackets containing the list of characters you want to match. Keep in mind, this is a list of possible characters to match but will only match one of them. For instance, ls, space, left-square bracket, 123abc, right-square bracket, .txt would match 1.txt, 2.txt, 3.txt, a.txt, b.txt, or c.txt. It will not match 123.txt. The character set matches one character, just like the question mark wildcard, but we have a more concise list of which characters to match. So, make sure you are in your chapter one directory of your extracted exercise files. In a terminal, type in ls, space, file, left-square bracket, abc, right-square bracket, .txt, and hit Enter. This will match filea.txt, fileb.txt, and filec.txt. To match a range of numbers, we can type in ls, space, file…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.