Shuf 命令随机从一个文件或文件夹中选择行/文件/文件夹。首先使用ls命令来显示文件夹的内容。
复制代码 代码如下:
# ls
Desktop Documents Downloads Music Pictures Public Templates Videos
# ls | shuf(shuffle Input)
Music
Documents
Templates
Pictures
Public
Desktop
Downloads
Videos
# ls | shuf-n1 (pick on random selection)
Public
# ls | shuf -n1
Videos
# ls | shuf -n1
Templates
# ls | shuf -n1
Downloads
注意:你可以把‘ n1'替换成‘n2'来输出两个随机选择或者使用 n3、 n4等数字输出其他任意的随机选择