Problem while using grep (multi-level) with the space-separated filepath.

Hi,
I've been trying to use grep to find out all the files which have two particular patterns in it (both pattern1 AND pattern2). I have a script to do the same, in which I'm getting the output of the first grep (with -l option) which contains the list of file paths and I'm trying to search for pattern2 in this file path. Things are fine as long as the file path has no space-separated path in it.
My script looks like this:
#!/bin/sh
path=`grep -l 'pattern1' /home/user1/*`
#Say the output of the same was ----> "/home/user1/new file"
grep -l 'pattern2' $path

The second grep above fails coz the value of $path is treated as 2 different paths (/home/user1/new AND file).
So I used sed to replace all " " with "\ ". For this I had to write the output to a file. When I "cat" the output of the sed formatted file as the filepath to my 2nd grep expression, it's still failing to get me the correct results.
Is my problem related to how "cat" deals with files or is there something else I must be doing?
If a file.txt has the following text in it:
/home/user1/new\ file
the following grep command fails (it consider that path as two different paths) in command-prompt too:
grep 'pattern' `cat file.txt`

Any light on this will be of great help!
Thanks
NJ

edited.

#!/bin/sh
temp=/tmp/aux.$$
grep -l 'patter1' /tmp/pro/* >$temp
while read path
do
  grep -l 'patter2' "$path"
done<$temp
rm -f $temp

works great!! thanks a ton!! :slight_smile:

---------- Post updated at 10:02 AM ---------- Previous update was at 09:56 AM ----------

Any idea why a path like "/home/user/new\ folder" doesn't work fine with grep when I populate this value from cat?

I mean, say a file (file.txt) had "/home/user/new\ folder" in it and in the shell script if I did the following:
path=`cat file.txt`
then the following grep command fails to give me the correct results:
/bin/egrep -l "pattern" "$path"

Any idea why that happens although I've quoted $path.