Q:

Bash: Move Content of Any Directory Named n10 Up One Level

I have a directory structure which has many directories named "n10" in it. These directories appear at many different levels deep from the root of my directory structure. A given "n10" directory can contain both files and other directories, but no "n10" directory has anywhere in the tree below it another directory (or file for that matter) named "n10".
I am using a RedHat Bash shell and my present working directory is the root of the directory structure described above. While sitting in this directory, I need to issue a command that will:
For every "n10" directory, I need to move everything in that directory up one level so that it is now parallel to the said "n10" directory. This will leave the "n10" directory empty.
Note that when a subdirectory of an "n10" directory is moved up one level as described above, it must retain the exact same tree structure it had before the move. Specifically, I am trying to say that it should not be "flattened" when it is moved.
My best attempt at this is:
find . -path \*n10 -execdir bash -c 'mv -t .. {}/*' \;

This results in this output:
mv: cannot move `./n10/config1' to `../config1': Directory not empty
mv: cannot move `./n10/config2' to `../config2': Directory not empty
mv: cannot move `./n10/config1' to `../config1': Directory not empty

I find that some files are copied to the root of my directory structure. I also find that when that happens with directories, the above errors result.
Does anybody know how I can fix this?

A:

See http://mywiki.wooledge.org/UsingFind#Complex_actions for discussion of safely invoking shell fragments from find.
find . -type d -name n10 \
  -exec bash -c '
     for arg; do
       cp "$arg"/* "${arg%/*}"
     done
  ' _ {} +

Note that -exec ... {} + is specified by POSIX, but only fairly recent versions of the standard; for older implementations of find, you may need to use {} ';' instead.

