I have a directory structure like this: m/n/o/p/q/r/s/t.
I want to find directories that match by name "r" and copy contents recursively from the parent-dir of the find-result (ie. "q/r/s/t" in this case - what would be achieved with 'cp -r q/r <dir_location>') onto another location.
Something like:
find m/n/o/p -type d -name "r" -exec cp -r "../{}" /<folder_to_copy_into> \;
I've tried experimenting with -printf %h and -maxdepth, but I'm not sure I have the correct syntax. I'm not sure if I should be piping into another find to get my intended result. (Goal is to only copy from one-parent-dir-above-from-find-results recursively into the other dir location).
As long as I can find dir named "r", I want to recursively copy everything from r's parent-dir onto a new dir-location. (eg: if I have m/n/o/p/q/r/s/t, I want "q/r/s/t" to be recursively copied onto the new dir-location).
r
's parent-dir" isr
and other files inq
, but notq
itself. Then you say "I wantq/r/s/t
to be recursively copied. So you do want to copyq
. Please clarify. It's "copy contents ofq
(i.e. everything fromq
)" vs "copyq
".