上QQ阅读APP看书,第一时间看更新
Complemented named character classes
In complemented named character classes, the first character after [ is caret, ^, and it is followed by the named character class, which is enclosed in '[:' and ':]'. For example, if you want to search for a line without letters (lowercase), we can write it as follows:
$ echo -e "a
\nb
\nc
\n1
\n2
\nd
\n3" | awk '/[^[:lower:]]/'
The output on execution of the preceding code is as follows:
1
2
3
We can mix the old and new POSIX styles, for example, to any number between 1-5 or any lowercase letter. For this, we can use the following:
$ echo -e "a\n1\ne\n5\nz\n8" | awk '/[1-5[:lower:]]/'
The output on execution of the preceding code is as follows:
a
1
e
5
z