grep 匹配的几个参数

grep -o

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

ps aux | grep python | grep -v grepgrep -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 匹配的几个参数

相关文章:

你感兴趣的文章:

标签云: