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 classes

Character classes - Bash Tutorial

From the course: Bash Patterns and Regular Expressions

Start my 1-month free trial

Character classes

- We have previously talked about the challenges with character sets. I've had character sets work in an interactive login, but break on an SSH login because the shell environment was different. Very similar to a character set is a POSIX-compatible character class. Character classes are consistent and reliable. They entail a bit more typing, but I'd really recommend you getting to know them. Make sure you're still inside your alphafiles directory inside of your chapter one exercise files. Now type in ls [[:upper:]] and hit enter. This matches all uppercase characters, including those with diacritic marks. This is more reliable and less reliant on the locale settings of the OS. Now let's try lowercase characters. Type in ls [[:lower]] and hit enter. Again, it shows all lowercase characters, including those with diacritic marks. Even when you change your locale setting, character sets won't get you the same results as character classes. Let's break down a character class to see how it…

Contents