Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
5 of 6 I couldn't find any version of head that has a '-z' option. Otherwise thanks for the improvement

The following copies the first 1000 files found in the current directory to $destdir. Though the actual files depend on the output returned by find.

$ find . -maxdepth 1 -type f |head -1000|xargs cp -t "$destdir"

You'll need the GNU implementation of cp for -t, a GNU-compatible find for -maxdepth. Also note that it assumes that file paths don't contain blanks, newline, quotes or backslashes (or invalid characters or are longer than 255 bytes with some xargs implementations).

EDIT: To handle file names with spaces, newlines, quotes etc, you may want to use null-terminated lines:

find . -maxdepth 1 -type f -print0 | head -n 1000 | xargs -0 -r -- cp -t "$destdir" --