I'm using grep to find files within a directory, containing a set of words. But grep search lines containing these words, what I want is grep to show me the files or file containing all those words even in different lines.
grep -lw "ből\|dének\|jeként\|jében\|jéből\|jéhez\|jének\|jéről\|jét\|jével\|jéül" *model.txt
But it isn't valid if the file contains one or two .. words. Must contain the entire set of words
How I can achieve this with bash?
I am using the code suggested by Tagwint
find -name '*model.txt' | while read f; do [[ "$(grep -o -w -f patterns $f| sort -u|wc -l)" -eq "$(cat patterns | wc -l)" ]] && echo $f; done
How could it be modified to also show the number of occurrences found in each file? Like..
685 01_táska.model.txt
687 02_dinnye.model.txt
685 03_kapu.model.txt
685 04a_nő.model.txt
685 04b_büdzsé.model.txt