I need to query java files which have both the strings 'rESTWSLib' and '500'. Both the strings could be anywhere in the document (i.e. line) and can be positioned anywhere on 0-infinite lines (position 0-n).
How to grep query for 'rESTWSLIB':
find -iname '*.java' -type f -exec grep -l "rESTWSLib" '{}' \; > ~/SMCrestwsList1.txt
output:
./some/file1.java
./some/file2.java
How to grep query for '500':
find -iname '*.java' -type f -exec grep -l "500" '{}' \; > ~/SMCrestwsList2.txt
output:
./some/file2.java
./some/file3.java
I need to combine both grep queries (or their results) so I am expecting this as result:
./some/file2.java
I have tried the solutions given in How to grep query all files for 2 strings
find -iname '*.java' -type f -exec grep -l "rESTWSLib" '{}' + | xargs grep -l "500" \; > ~/SMCrestwsList3.txt
But, since few files have spaces in their names, only partial output is given with the below error messages:
grep: ;: No such file or directory
grep: ./cdrm/bat/OpportunityManagement/Verify: No such file or directory
The filename is 'Verify something something'.
How can I tweak this to accept the spaces in the filename?