2015-07-12 53 views
1

我使用下面的命令来搜索文本用grep检索模式匹配后,接下来的2行文字:用grep

grep --include=*.{php,py} -rnw 'DIR' -F -e 'TEXT' 

考虑以下文字:

This is so funny 
This is pyramid 
Hello World 
How are you 

如何修改如果我指定'funny'作为匹配表达式,上面的grep命令(或者是否有其他选择)可以获取下两行代码?

grep --include=*.{php,py} -rnw 'DIR' -F -e 'funny' 

回答

2

您可以使用grep -A <number>获得匹配后的行数。