Copy Random Files
You could use shuf : shuf -zn8 -e *.jpg | xargs -0 cp -vt target/ shuf shuffles the list of *.jpg files in the current directory. -z is to zero-terminate each line, so that files with special characters are treated correctly. -n8 exits shuf after 8 files. xargs -0 reads the input delimited by a null character (from shuf -z ) and runs cp . -v is to print every copy verbosely. -t is to specify the target directory.