Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Your Answer


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.