From 17057247a9521195d5b8f5ec4be8a3e4b68f3547 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Wed, 7 Sep 2022 13:20:01 +0200 Subject: [PATCH] Added SED character classes --- knowledge base/sed.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/knowledge base/sed.md b/knowledge base/sed.md index 0a7321c..31a32a9 100644 --- a/knowledge base/sed.md +++ b/knowledge base/sed.md @@ -15,8 +15,27 @@ sed /etc/fstab \ -e '/#.*\s*swap\s*.*/d' ``` +## Character classes and bracket expressions + +| Class | Description | +| ----- | ----------- | +| `[[:alnum:]]` | alphanumeric characters `[[:alpha:]]` and `[[:digit:]]`; this is the same as `[0-9A-Za-z]` in the `C` locale and ASCII character | +| `[[:alpha:]]` | alphabetic characters `[[:lower:]]` and `[[:upper:]]`; this is the same as `[A-Za-z]` in the `C` locale and ASCII character encoding | +| `[[:blank:]]` | blank characters `space` and `tab` | +| `[[:cntrl:]]` | control characters; in ASCII these characters have octal codes 000 through 037 and 177 (DEL), in other character sets these are the equivalent characters, if any | +| `[[:digit:]]` | digits `0` to `9` | +| `[[:graph:]]` | graphical characters `[[:alnum:]]` and `[[:punct:]]` | +| `[[:lower:]]` | lower-case letters `a` to `z` in the `C` locale and ASCII character encoding | +| `[[:print:]]` | printable characters `[[:alnum:]]`, `[[:punct:]]` and `space` | +| `[[:punct:]]` | punctuation characters `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`, `*`, `+`, `,`, `-`, `.`, `/`, `:`, `;`, `<`, `=`, `>`, `?`, `@`, `[`, `\`, `]`, `^`, `_`, `` ` ``, `{`, `\|`, `}` and `~` in the `C` locale and ASCII character encoding | +| `[[:space:]]` | space characters `tab`, `newline`, `vertical tab`, `form feed`, `carriage return` and `space` in the `C` locale | +| `[[:upper:]]` | upper-case letters `A` to `Z` in the `C` locale and ASCII character encoding | +| `[[:xdigit:]]` | hexadecimal digits `0` to `9`, `A` to `F` and `a` to `f` | + ## Further readings - [GNU SED Online Tester] +- [Character Classes and Bracket Expressions] +[character classes and bracket expressions]: https://www.gnu.org/software/sed/manual/html_node/Character-Classes-and-Bracket-Expressions.html [gnu sed online tester]: https://sed.js.org/