|NO.Z.00007|——————————|LinuxShell|——|Linux&Shell&字符截取和替换命令.V05|——|正则表达式|
一、正则表达式
### --- 例子一:如果要想让 awk 识别字符串,必须使用“//”包含,例如:
~~~ 注:打印 Liming 的成绩
[root@localhost ~]# awk '/Liming/ {print}' student.txt
1 Liming 82 95 86 87.66
### --- 例子二:当使用 df 命令查看分区使用情况是,如果我只想查看真正的系统分区的使用状况,
~~~ 而不想查看光盘和临时分区的使用状况,则可以:
~~~ 注:查询包含有 sda 数字的行,并打印第一字段和第五字段
[root@localhost ~]# df -h | awk '/sda[0-9]/ {printf $1 "\t" $5 "\n"} '
/dev/sda8 6%
/dev/sda6 1%
/dev/sda5 14%
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
浙公网安备 33010602011771号