@DopeGhoti's answer is the right approach, but let me flesh it out a bit, for those new to split
(like me):
find ./J0902-405 -maxdepth 1 -name '*.evt' -type f -printf '%f\n' | \
split -l 999 -d - files_xselect.list.
-name ...
with a quoted filename pattern lets find do the pathname expansion (as opposed to the shell - no point in letting both the shell and find
do the work).
-printf '%f\n'
ensures that only filenames (no path components) are output, as in the OP.
-l 999
specifies the split size in lines; default is 1000.
-d
causes numerical suffixes to be used for the output files (00
, 01
, ...) rather than the default letters (aa
, ab
, ...) [note: won't work on OSX]; default suffix length is 2; to control the number of digits/chars. in the suffix, use -a {length}
.
-
causes split
to read from stdin - in this case, the output from find
.
files_xselect.list.
is the output-file prefix; thus, we get files files_xselect.list.00
, files_xselect.list.01
, ...
If you want more control over the output filename - e.g., to move the suffix data to a different part of the filename - you can use the --filter
option (note: won't work on OS X), which accepts a shell command to which the output data for each file is piped, along with variable $FILE
containing the name of the respective output filename; this gives you the chance to modify the output filename based on it:
For instance, to create output files named files_xselect.00.list
, ... - i.e., to place the suffix data before the filename extension, you'd use:
... | split -l 999 -d --filter='> ${FILE}.list' - 'files_xselect.'