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

后端 未结 11 1088
陌清茗
陌清茗 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:58

    @Marcin: awk example non-greedy:

    awk '{if ($0 ~ /Start pattern/) {triggered=1;}if (triggered) {print; if ($0 ~ /End pattern/) { exit;}}}' filename
    

提交回复
热议问题