grep'ing for specific directories, and using the output to move files

Hello, this is probably another really simple tasks for most of you gurus, however I am trying to make a script which takes an input, greps a specific file for that input, prints back to screen the results (which are directory names) and then be able to use the directory names to move files. Something like;

read -p "Enter Comp ID: " id

grep $id /usr/local/test/service/bin/services.sh | grep DEST_PREFIX | grep -v "#"| awk -F/ '{print $2}' | sort -u > clients

cp /data/new/* /var/tmp/"$clients"/inbound

So basically everything in the /data/new directory will get copied to all the folders the grep results bring back - if that makes sence.

Can anyone advise on the best way of doing so?

Thank you in advanced.

Hi,

if i understand you correctly your commands will result in a file
consisting for directory names line by line? If this is so, try:

while read clients
do
  cp /data/new/* /var/tmp/"$clients"/inbound
done < clients

If my assumption is wrong, please post an example of your clients-file
and the files to be copied.

HTH Chris