The bracket character set in Linux:
[:d Igit:] numeric characters, 0-9;
[: Lower:] Lowercase alphabetic characters, A-Z;
[: Upper:] Uppercase characters, A-Z;
[: Alpha:] Uppercase and lowercase alphabetic characters, a-za-z;
[: Alnum:] numbers, alphabetic characters, 0-9a-za-z;
[: Space:] Blank (whitespace) character;
[: Blank:] Space (space) and Positioning (tab) characters;
[: Graph:] non-whitespace (nospace) characters;
[:p UNCT:] punctuation characters;
[:p rint:] printable characters;
[: Cntrl:] control character;
[: xdigit:] hexadecimal character;
Test file:
[email protected] ~]# cat test 123123 abcabc #此行有空格; abc123abc ABC abcABC123 123 ABCA,B.C #此行无空格; AAbb.
Example 1:[:d igit:] numeric character, 0-9;
[[email protected] ~]# grep ' [[:d igit:] ' test 123123 abcabc123abc123 123 AbC
Example 2:[:lower:] Lowercase alphabetic characters, A-Z;
[[email protected] ~]# grep ' [[: Lower:] ' test 123 ABCABC ABC123ABC ABC 123 Abca,b.caabb.
Example 3:[:upper:] Uppercase characters, A-Z;
[[email protected] ~]# grep ' [[: Upper:] ' test abc abc abcABC123 123 Abcaabb.
Example 4:[:alpha:] Uppercase and lowercase alphabetic characters, a-za-z;
[[email protected] ~]# grep ' [[: Alpha:]] ' test 123 abcabc abc123abc ABC abcABC123 123 Abca,b.caabb.
Example 5:[:alnum:] numbers, alphabetic characters, 0-9a-za-z;
[[email protected] ~]# grep ' [[: Alnum:] ' test 123123 abcabcabc123abc ABC abcABC123 123 Abca,b.caabb.
Example 6:[:space:] Blank (whitespace) character;
[[email protected] ~]# grep ' [[: Space:]] ' test 123 ABC abc abc ABC 123 ABC
Example 7:[:blank:] Space (space) and Positioning (tab) characters;
[[email protected] ~]# grep ' [[: Blank:]] ' test 123 ABC abc abc ABC 123 ABC
Example 8:[:graph:] Non-whitespace (nospace) characters;
[[email protected] ~]# grep ' [[: Graph:]] ' test 123123 abcabcabc123abc ABC abcABC123 123 Abca,b.caabb.
Example 9:[:p UNCT:] punctuation characters;
[[email protected] ~]# grep ' [[:p UNCT:] ' Test A,b.caabb.
This article is from the "Ilinux" blog, make sure to keep this source http://shenzhijin.blog.51cto.com/1741240/1865291
The bracket character set in Linux