Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.