I am running this command to find all my files that contain (with help of regex)"someStrings" in a tree directory.
grep -lir '^beginString' ./ -exec cp -r {} /home/user/DestinationFolder \;
It found files like this:
FOLDER
a.txt
-->SUBFOLDER
a.txt
---->SUBFOLDER
a.txt
I want to copy all files and folder, with the same schema, to the destination folder, but i don't know how to do it. It's important copy files and folder, because several files found has the same name and I need to keep it.