xargs can indeed be part of the mix. Some more info:
grep has an option that makes it display the filename only, not the string it found. Use this option and do something like that:
Code:
grep -appropriateoptions directory | xargs mv {} targetdirectory
This would move all files to the same target directory.
If you want to keep the structure of the source directory tree on the target, you can also do:
Code:
grep -appropriateoptions directory | cpio -pdv -possiblysomemoreoptions targetdirectory