From the course: Bash Patterns and Regular Expressions

Unlock the full course today

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

Character sets

Character sets - Bash Tutorial

From the course: Bash Patterns and Regular Expressions

Start my 1-month free trial

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…

Contents