As an example, I have this directory structure:

|- a
  \- 1
|- b
  \- 2
|- c
  \- 3

I want to copy 1, 2, 3 to something like this:

|- 1
|- 2
|- 3

My idea is to write a bash script that traverses the directories and copy files from them, but I would like to know any simpler or better methods for this.

  • 1
    Please note that superuser.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read How to Ask. – DavidPostill May 21 at 7:46
  • Look at man find, especially the -exec option. – gronostaj May 21 at 7:52
  • 1
    @gronostaj Thank you for pointing me to the right direction, I tried find . cp {} ./dest \; and it worked. – Takase May 21 at 8:00

Browse other questions tagged or ask your own question.