我知道如何使用grep,但现在pcregrep。我试过了:
pcregrep -M -1 -rl '."\n' 2012 -name en*.txt
但它不起作用?
基本上我希望它在文件夹2012中以递归方式显示名称为en_blahblahblah.txt的所有文件中显示前面一行和下面一行。但是我尝试了该命令并且它不起作用。 我需要使用pcregrep,因为grep不支持换行符。
答案 0 :(得分:0)
使用-A lines
和-B lines
选项。
[aman@aman test]$ pcregrep -M -B 2 -A 2 "C\nD" temp
And failed to add the T and M; Another called my grammar vile
C
D
And criticized my writing style.
Each day I scan each Subject line
来自手册页
-A number, --after-context=number Output number lines of context after each matching line. -B number, --before-context=number Output number lines of context before each matching line.