Multiple search in multiple files

Hello,

I would like to perform a search of several different strings in different files. I have the ouput of a unix command X which is for instance:

aaa
bbb
ccc

and I would like to look for each of these three strings into several files: file1 file2 etc.

I have come up with a solution that works... but slowly and not very neatly..
I am redirecting the output I get from command X to a file and then I read this file line by line performing the search with grep:

[several commands] > tmpFile
while read line
do
grep $line file1 file2 file3 >> finalFile
done < tmpFile

is it possible to avoid the loop by piping the output of X to a sed command for ex ?

Thank you for any help
Max

Use something like:

command |xargs -i ksh -c 'grep {} file'

That's perfect !!!!

Thanks a lot

Max