I am trying to do a search in one directory containing a large number of html files, to find those files that contain the exact values on the same line. This should work:
grep -iwc 'word1' -sl | xargs grep -iwc 'word2' -s
But that only works on one file at a time. I tried something like this:
find . -iname '*html' | xargs grep -iwc 'word1' -sl | xargs grep -iwc 'word2' -s
But that seems to display files containing any of the two values, so even those that are not on the same line.
The output should only be the file names and the number of occurrences like:
file.html:2
If it possible to group those 2 greps? Or another way to do this search?
An extended regex may help. Something like this perhaps?
Since you only have two words you’re looking for, it’s not too hard to list off all the ways to order them.