Copying files with different extensions but one of them contains 'pattern'
by sandykoufax from LinuxQuestions.org on (#4Z861)
I have several files in a directory and need to copy to a different location those which contain within the file -not within the name- a certain string.
After that, I also need to copy another set of files with matching names but different extensions to the same location as those which matched my previous search.
So far I know how to find the string using
grep 'pattern' *.ext1
and I tried to use
grep 'pattern' *.ext1 | xargs cp /newlocation
but to no avail.
Thank you


After that, I also need to copy another set of files with matching names but different extensions to the same location as those which matched my previous search.
So far I know how to find the string using
grep 'pattern' *.ext1
and I tried to use
grep 'pattern' *.ext1 | xargs cp /newlocation
but to no avail.
Thank you