I am trying to find files that include either of the following two patterns:
select AND into
SELECT AND INTO
select AND INTO
SELECT AND into
grep -r 'INTO\|SELECT' .
If the patterns have to occur on the same line, you can use
grep -r '\(INTO.*SELECT\)\|\(SELECT.*INTO\)' .
The two alternatives are to cover either order. If the two patterns can occur on separate lines, try this:
grep -r -Z -l 'INTO' . | xargs -0 grep 'SELECT'
The first grep will print the names (
-l) of the files that have
xargs -0 work together to pass those names to a second grep, which looks for
Note thanks to @ghoti: for grep versions other than GNU, try
--null instead of