Reputation: 395
I want to show text files that contain a string and to count them. My code is:
grep -l "string" file1.txt file2.txt | wc -l
It shows the number of files that contain "string". How can I show the names of the files too?
Upvotes: 2
Views: 85
Reputation: 50815
How about tee
ing it?
grep -l 'string' file1.txt file2.txt | tee >(wc -l)
Upvotes: 1