码迷,mamicode.com
首页 > 其他好文 > 详细

grep 匹配的几个参数

时间:2015-03-02 21:02:42      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:grep   linux   

grep -o

grep 忽略匹配自己 ps aux | grep python 总是会看到一个包含grep的匹配项,这是不符合我们的匹配期望的。可以这样过滤掉grep这个匹配项。可以用下面这个命令来实现

ps aux | grep python | grep -v grep

grep -F

grep -F 等价于 fgrep。 egrep 等价于 grep -E。
下面是找到的资料

You have a file with a list of say ten Unix usernames in plain text. You want to search the group file on your machine to see if any of the ten users listed are in any special groups:

grep -F -f user_list.txt /etc/group

The reason the -F switch helps here is that the usernames in your pattern file are interpreted as plain text strings. Dots for example would be interpreted as dots rather than wild-cards. -f 表示内容从 user_list.txt 中读取。

grep -o

grep -o 输出匹配的内容。

grep -E

支持扩展的正则表达式。

grep 匹配的几个参数

标签:grep   linux   

原文地址:http://blog.csdn.net/typeof_/article/details/44014619

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!