Display filename before matching line

后端 未结 6 438
挽巷
挽巷 2020-11-30 16:28

How can I get grep to display the filename before the matching lines in its output?

6条回答
  •  -上瘾入骨i
    2020-11-30 17:29

    No trick necessary.

    grep --with-filename 'pattern' file
    

    With line numbers:

    grep -n --with-filename 'pattern' file
    

提交回复
热议问题