
That's the power of Linux/Bash for you, but out of curiosity, why would you want to do that? You can enhance by ensuring your source objects are not directories too unless you're sure that'll never happen by checking before hand or using the -a option. cp will fail otherwise. On 12/09/24 14:59, Peter Reutemann wrote:
I was just wondering how I can copy a random subset of files from one folder to another. And, of course, there bash utilities for that... ;-)
I came across two solutions for copying 20 files from the current directory into DEST: - shuf cp `ls | shuf -n 20` DEST
- sort (using random sort) ls | sort -R | tail -20 | while read file do cp $file DEST done
source: https://stackoverflow.com/questions/414164/ -- Mark Smith E: mark(a)winksmith.com