Linux 中grep命令中 -P选项的作用

 

001、

 -P选项表示 perl正则兼容

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt       ## 测试数据
01
02
03
04
05
中国农副业
06
07 河南
08
09
10
[root@PC1 test]# cat a.txt | grep '[\x{4e00}-\x{9fff}]+'        ## 一一般正则
[root@PC1 test]# cat a.txt | grep -P '[\x{4e00}-\x{9fff}]+'     ## 兼容perl正则
中国农副业
07 河南

 。

 

posted @ 2024-07-09 13:06  小鲨鱼2018  阅读(24)  评论(0编辑  收藏  举报