From the course: Bash Patterns and Regular Expressions

Unlock the full course today

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

Matching characters and words

Matching characters and words - Bash Tutorial

From the course: Bash Patterns and Regular Expressions

Start my 1-month free trial

Matching characters and words

- [Interviewer] We're going to start our discussion on extended regular expressions by talking about how to match single characters and words. To match one character of any type except null, we use a dot. To specify which character to match while escaping it we use a character set with square brackets. If you haven't watched the video on character sets in chapter one of this course, you should do so now. Also, watch the video on the affect of locale on searches. This will explain some very strange behavior with character set ranges. If you want to match A, B or C, we'll do left square bracket A, B, C, right square bracket. Note that it will only match one character, and that character can be A, B or C. If you want to negate the match, for instance we want to match one character, but it cannot be A, B or C, we precede the match with a circumflex. You can do ranges with character sets too. I won't spend too much time with this as we've already covered it in the glob section of this…

Contents