How can I search for a multiline pattern in a file?

后端 未结 11 1012
陌清茗
陌清茗 2020-11-22 14:59

I needed to find all the files that contained a specific string pattern. The first solution that comes to mind is using find piped with xargs grep:

11条回答
  •  花落未央
    2020-11-22 15:56

    Here is the example using GNU grep:

    grep -Pzo '_name.*\n.*_description'
    

    -z/--null-data Treat input and output data as sequences of lines.

    See also here

提交回复
热议问题