Server Fault is a question and answer site for system and network administrators. 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 have a folder called "employee" and within that folder there are sub-folders with each employee name.

>> amar
>> akbar
>> anthony

Each of these folders contain 1 or 2 files. There are around 50 employees. I want to copy all those files into a new folder "/home/employee_files" without the sub-folders. In other words, all the files should be available when I list "ls /home/employee_files"

share|improve this question

closed as off topic by womble, Lucas Kauffman, Scott Pack, freiheit, Ward Aug 24 '12 at 3:49

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 3 down vote accepted
$ cp employee/*/* /home/employee_files/
share|improve this answer
find /home/attachments/ -type f -exec cp {} /home/attachments_all/ \;

Beware that if two files have the same name, you'll only end up with one of them.

An alternate approach is to copy files to a name that is a hash of their contents.

cp "$1" /home/attachments_all/`sha1sum "$1" | cut -f 1 -d ' '`

That will give you a unique copy of each file regardless of what it was named before. You can alter the script to provide you an index file.

share|improve this answer
find /home/attachments/ -name "*.*" -exec scp {} /home/attachments_all/ \;
share|improve this answer
Because, of course, all files have a period in them, but a directory never would... – womble Aug 26 '11 at 9:58

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