Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm attempting to find a directory A that could be in a variable location and copy another directory B into the found directory. So, I'd like to find directory A, and copy Directory B into Directory A.

find -name "foo.bundle"; cp directory B into the found directory.

If there are multiple matching A directories, I want to copy B to each of them.

share|improve this question
1  
Move or copy? There's a difference... –  Hauke Laging Feb 28 '13 at 20:46
    
See unix.stackexchange.com/help/user-merge for help with your accounts. –  Gilles Mar 1 '13 at 0:12
add comment

1 Answer

find /search/tree/root -type d -name "foo.bundle" -exec cp -Rp /path/to/B {} \;

Edit 1

Some explanation has been requested...

  1. -type d limits the search results to directories
  2. -exec ... ; executes the command; {} is replaced by the path of the current match; ";" is required by find and it has to be quoted for the shell.
share|improve this answer
    
The guy who asked this probably isn't a shell expert, so it might be helpful if you provided some explanation for his learning. If you do, +1. –  Kazark Feb 28 '13 at 21:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.