Linux shuf --随机选择器

来源:互联网 发布:linux服务器份额2016 编辑:程序博客网 时间:2024/05/10 10:48

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等数字输出其他任意的随机选择

0 0