Grep Recursive and Count

后端 未结 6 662
夕颜
夕颜 2021-02-13 18:14

Need to search a directories with lots of sub-directories for a string inside files:

I\'m using:

grep -c -r \"string here\" *

How can I

6条回答
  •  感动是毒
    2021-02-13 19:12

    Using Bash's process substitution, this gives what I believe is the output you want? (Please clarify the question if it's not.)

    grep -r "string here" * | tee >(wc -l)
    

    This runs grep -r normally, with output going both to stdout and to a wc -l process.

提交回复
热议问题