This question already has an answer here:
I am looking for a command options for
find files with the occurences of
grep -r -e foo -e bar .
shows files which have only
foo or only
bar and files which have
Is it possible with
grep to find only files which have both
bar (and display the lines that match either
bar or both in those files only)?
echo foo > file1 echo bar > file2 (echo foo;echo;echo bar) >file3 echo barfoo > file4
the grep cmd:
grepcmd -r -e foo -e bar . ./file3:foo ./file3:bar ./file4:barfoo