Searching multiple words?
How to search multiple words in multiple lines, inside a directory including sub-directory? Pls. give easy example.
I want to search the files (in /xx folder and all subfolders) that have header.h included and used x() function. I tried $grep -r "header.h" | grep -r "x(" /Folder/subfolder/ > search.log |
Maybe something like this is what you're looking for:
Code:
grep -lr 'header\.h' /xx/* | xargs grep -l 'x(' |
i hope it help you
Quote:
|
Quote:
Sorry to say but both of above commands didn't work for me. |
I think my question is not clear.
I want to search files (basically .cc files) in /xx folder and subfolders inside /xx folder. Those files (actually, they are *.cc files) must have #include "header.h" AND x() function. Clearly, I wanna *.cc files that have 'header.h' & 'x()'. I tried several ways, and got only files with header.h OR x(). |
Didn't my solution (above) work for you?
|
Code:
grep -lr 'header\.h' /xx/* | xargs grep -l 'x(' You might want to add .cc after the star to only match .cpp files. There needs to be at least on .cc file in your base target directory. You could also use find </path/to/directory> -type f -name "*.cc" | xargs grep -l 'x(' Try the left hand side command first to see if you are getting a list of files. If you are, then add the | xargs ... part. |
Quote:
|
All times are GMT -5. The time now is 05:18 PM. |