grep output to show only matching file

后端 未结 4 1960
轻奢々
轻奢々 2020-12-22 21:33

What is the option for grep that will allow me only to print the matching file and not the line within a file that matches the criteria?

相关标签:
4条回答
  • 2020-12-22 21:50

    You can use the Unix-style -l switch – typically terse and cryptic – or the equivalent --files-with-matches – longer and more readable.

    The output of grep --help is not easy to read, but it's there:

    -l, --files-with-matches  print only names of FILEs containing matches
    
    0 讨论(0)
  • 2020-12-22 21:52
    grep -l 
    

    (That's a lowercase L)

    0 讨论(0)
  • 2020-12-22 22:01

    -l (that's a lower-case L).

    0 讨论(0)
  • 2020-12-22 22:02

    Also remember one thing. Very important
    You have to specify the command something like this to be more precise
    grep -l "pattern" *

    0 讨论(0)
提交回复
热议问题