How can I used grep to find a file containing 2 strings? -


i searching definition of macro in project containing hundreds of source code files.

i sure macros defined in single file.

if grep -r search single macro, on 1000 hits occur.

i search each file, , find files containing both macro names.

can done grep?

for example this:

grep -r "macro1" , "macro2" ./ 

another way is

grep -rlz 'macro1' ./ | xargs -0 grep -l 'macro2' 
  • grep -rlz 'macro1' ./ give filenames containing macro1
    • -z separate filenames null character
  • xargs -0 grep -l 'macro2' give filenames containing macro2

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -