character class
A regular expression or glob part in square brackets that matches any one character from a set, such as [abc] or [a-z].
In more detail
A caret just inside the bracket negates it, so [^abc] matches anything else. Named classes such as [[:space:]], [[:digit:]] and [[:lower:]] respect the language settings and are safer than ranges. tr uses the same names, as in tr '[:lower:]' '[:upper:]'.
Related terms
- regular expression — A pattern language for matching text, where characters such as ., *, ^ and $ have special meanings.
- glob pattern — A pattern that matches names using * for any run of characters, a question mark for one character and [abc] for one of a set.
- tr — The command that replaces, squeezes or deletes single characters as text passes through it.
Taught in
- Finding Lines: grep And Regular Expressions — Bash Scripting & Command Line Automation
- Reshaping Text: cut, sort, uniq, tr, sed, awk — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation