I am trying to do a search with find and pass the results into grep. Grep has to find the files matched against string1 and string2 and string3.
I have the following command:
#/bin/bash
searchpath="/home/myfolder"
string1="abc"
string2="def"
string3="ghi"
find `echo "${searchpath}"` -type f -print0 | xargs -0 grep -l -E '"${string1}".*"${string2}".*"${string3}"'
But the result is blank, but when I do:
find /home/myfolder -type f -print0 | xargs -0 grep -l -E 'abc.*def.*ghi'
I get results. What am I doing wrong?