Copying a subset of files from a directory on CentOS

I had a huge number xml files (somewhere close to 100k files) and i needed to copy just a 1000 of them for a few tests on CentOS. I wasn’t interested in the order of the files, simply just any 1000 will do.

After trolling all over the internet, if found this simple solution.

 find $targetDir -maxdepth 1 -type f |head -1000|xargs cp -t $destDir

Where $targetDir was the path to the folder containing the large set of files, and $destDir is the folder in which i wanted to copy the 1000 files into.

Sweet and simple. Gleaned from here