I am looking for a command options for grep to
find files with the occurences of foo and bar.
Grepping with
grep -r -e foo -e bar .
shows files which have only foo or only bar and files which have foo and bar.
Is it possible with grep to find only files which have both foo and bar (and display the lines that match either foo or bar or both in those files only)?
Example:
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