20.4.3. Useful categories of characters (as defined by the POSIX standard)
This information has been taken from the grep info page with a tiny amount of editing, see [10] in the Prev for further information.
[:upper:] uppercase letters
[:lower:] lowercase letters
[:alpha:] alphabetic (letters) meaning upper+lower (both uppercase and lowercase letters)
[:digit:] numbers in decimal, 0 to 9
[:alnum:] alphanumeric meaning alpha+digits (any uppercase or lowercase letters or any decimal digits)
[:space:] whitespace meaning spaces, tabs, newlines and similar
[:graph:] graphically printable characters excluding space
[:print:] printable characters including space
[:punct:] punctuation characters meaning graphical characters minus alpha and digits
[:cntrl:] control characters meaning non-printable characters
[:xdigit:] characters that are hexadecimal digits.
These are used with
The above commands will work with most tools which work with text (for example: tr ).
For example (advanced example), this command scans the output of the dir command, and prints lines containing a capital letter followed by a digit:
ls -l | grep '[[:upper:]][[:digit:]]'
The command greps for [upper_case_letter][any_digit], meaning any uppercase letter followed by any digit. If you remove the [ ] (square brackets) in the middle it would look for an uppercase letter or a digit, because it would become [upper_case_letter any_digit]
Prev
Home
Next
Duplicating disks
Up
Appendix
* License

