I am trying to search for the string "rGEO"
in a directory by using the following commands:
find . -name "*" -type f -print | xargs grep "rGEO"
./home/oper1/AgencyTape/geo/exe/gngeo.cmd:${WEB_DIR}/exe/web_reports.sh -aGN -d${prev_ccyy}${prev_mm} -rGEO -nomail
In this case, I get back the file name which has the matching line, as well as the line which matches the above string.
find . -name "*" -type f -exec grep "rGEO" {} \;
In this case, I get back:
${WEB_DIR}/exe/web_reports.sh -aGN -d${prev_ccyy}${prev_mm} -rGEO -nomail
The file which contains the line isn't printed - and, as you can see, there is a lot of difference between the two outputs.
Using xargs
gives more clear and precise output.
My question is: what is the difference between the two commands? To me, they seem to be performing the same logic, but getting different results.