0

Hi I want to count particular lines using grep for all files in a folder

I know doing

find . -name 'FileName' | xargs wc -l

Helps with counting lines for all files. But I wonder how can I include grep in it.

Ideally I want to do grep @ FileName | wc -l for all the files in the folder. Thanks, Mitra

  • 1
    What are you *actually* trying to do? Get a count of matching lines in all the `.php` files in the current directory? In the current directory and all sub-directories? – Etan Reisner Jul 20 '15 at 14:04
  • 1
    Ok, this is really rather outside the purview of SO, but before I flag this post I'll just suggest you look at the `-c` flag on grep. Specifically, I would do `find . -name 'FileName' -exec grep -c '@' '{}' \+` or something like that. – dcsohl Jul 20 '15 at 14:32
  • This works... Thanks a lot :) – user3042163 Jul 20 '15 at 15:17

0 Answers0