I currently have 3TB of data on a disk with small to medium files in hundreds of folders. I need to find certain text files witch contain certain words ( more than one word ). I've already tried grep-ping for them. This works as it prints the path to every file. But this is a long list and I'm now looking for a workable way to copy them to another folder.
any ideas ?
Is there some way to put -exec cp -rv /estinationfolder in the syntax and have it copy all results to the folder ?
Yes , certainly there is a way.
You can pipe the grep output to copy command and provide required destination directory.
Here is a example,
this script will copy files to destination path provided in destination_path variable
Best part with this is, it will copy the files while preserving the full path.