加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

grep命令的-o和-P选项

发布时间:2020-12-15 20:51:20 所属栏目:大数据 来源:网络整理
导读:先看man中介绍:?????? -o ,--only-matching: ????????????? Show only the part of a matching line that matches PATTERN. -P ,--perl-regexp: ????????????? Interpret PATTERN as a Perl regular expression. ? 例如 #?? echo "helloworld123456"| gre

先看man中介绍:??????
-o,--only-matching:
????????????? Show only the part of a matching line that matches PATTERN.
-P,--perl-regexp:
????????????? Interpret PATTERN as a Perl regular expression.

?

例如

#?? echo "helloworld123456"| grep -o -P '/d+'

?

返回? 123456

#echo "helloworld123456"| grep -o -P '[a-z]+'

返回? helloworld

?

-P 选项是利用PERL的正则语法进行匹配

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读