shell 的正则表达式 grep

以上例子的目的在于,正则表达式只能用grep -n 命令中才有作用。在ls中,他的意义是不同的,例如*符号。

grep命令的解析

其中,几个特殊的正则表达式:

[[:alpha:]] 代表 字母
[[:alnum:]] 代表 字母与数字字符

[:alnum:]'
Alphanumeric characters: `[:alpha:]' and `[:digit:]'.

`[:alpha:]'
Alphabetic characters: `[:lower:]' and `[:upper:]'.

`[: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 1 2 3 4 5 6 7 8 9'.

原文地址:https://www.cnblogs.com/Lonelychampion/p/11175099.html