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 directory with almost 100,000 files inside. I want to copy 20,000 of them to another directory. Is it possible to do this with the cp command or is there any other way?

share|improve this question
Which 20,000 do you want to copy? – symcbean Aug 29 '11 at 11:26
up vote 1 down vote accepted
for FILE in `find /your/directory ! -type d  | head -n 20000`; do cp $FILE /destination/dir/; done
share|improve this answer

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.