这里是一个使用GNU sort的随机选项的脚本:
原文链接:https://www.f2er.com/bash/391937.htmlls |sort -R |tail -$N |while read file; do # Something involving $file,or you can leave # off the while to just get the filenames done