|
Here is a cool trick that I'm borrowing from cfajohnson... First put a random number in front of each file name:
ls | awk 'BEGIN {srand()} {printf "%.0f %s \n",rand()*99999, $0; }'
then sort it. This will put the lines in a random order. Then just pick the first few lines:
ls | awk 'BEGIN {srand()} {printf "%.0f %s \n",rand()*99999, $0; }' |sort -n | head -2 | awk '{print $2}'
|