Skip to content

Instantly share code, notes, and snippets.

@all4miller
Last active December 24, 2019 05:03
Show Gist options
  • Save all4miller/b5769b42b7633dce2f4e75228163c58c to your computer and use it in GitHub Desktop.
Save all4miller/b5769b42b7633dce2f4e75228163c58c to your computer and use it in GitHub Desktop.
SED Special Character Classes

Special Character Classes

The following list includes the special character classes which you can use:

[[:alpha:]] Pattern for any alphabetical character, either upper or lower case.
[[:alnum:]] Pattern for 0–9, A–Z, or a–z.
[[:blank:]] Pattern for space or Tab only.
[[:digit:]] Pattern for 0 to 9.
[[:lower:]] Pattern for a–z lower case only.
[[:print:]] Pattern for any printable character.
[[:punct:]] Pattern for any punctuation character.
[[:space:]] Pattern for any whitespace character: space, Tab, NL, FF, VT, CR.
[[:upper:]] Pattern for A–Z upper case only.

You can use them like this:

$ echo "abc" | awk '/[[:alpha:]]/{print $0}' 
$ echo "abc" | awk '/[[:digit:]]/{print $0}' 
$ echo "abc123" | awk '/[[:digit:]]/{print $0}' 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment