Skip to main content
added 57 characters in body
Source Link

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).

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) 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).

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).

added 11 characters in body
Source Link

I have a directory structure like this: m/n/o/p/q/r/s/t I.

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) onto another location.

Something like:

find m/n/o/p -type d -name "r" -exec cp -r "../{}" /<folder_to_copy_into> ;

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).

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) 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).

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) 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).

Source Link

Find directory matching a specific name and recursively copy from the parent-dir of find search-results

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) 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).