I've got a directory that contains directories that contain directories that contain files.  I'd like to select two files at random from each leaf directory.  I found this question about selecting from a single directory, but running it in each of several hundred directories would be a pain.
Selecting a random sample from a directory tree
shell script;files;directory
With a fixed depth of the directory structure (per your description, a directory with subsubdirectories with files), you could do something like:for subsubdir in $directory/*/*/do    find $subsubdir -type f | shuf -n 2done | shufThe final | shuf in the assumption that you want the list to be randomized as a whole, and not sorted by directory. Otherwise just drop it.If you expect newlines in your filenames, you can switch to zero-terminated list of files.