I have a collection of files ( *.zip, *.txt, *.tar.gz, *.doc, ...etc ). These files reside within a path. I want to find all the files ( *.txt), then copy, only, the text files that contain specific words ( e.g LINUX/UNIX).
I ran the following:
find . -name "*.txt" | grep 'LINUX/UNIX'
This command was able to find all the text files, then "grep" filtered the resultant text files by listing only the text files that contain 'LINUX/UNIX'.
How can I copy these final files (i.e. the text files that contain 'LINUX/UNIX') to a specific path of choice?
I tried to apply
find . -name "*.txt" | grep 'LINUX/UNIX' | xargs cp <to a path>
But it didn't work