Using the code in this answer, I can easily copy a file containing specific text from one folder to another. With the -r
option I can also search inside directories recursively.
The result is that now I have a lot of files copied in the destination directory. What if I want to preserve the directory hierarchy while copying the files?
It's a lot like this or this question, but with the added difficulty that I have to search for specific text inside the files.
FWIW, I'm on Ubuntu 14.04 x64