您的位置:首页 > 运维架构 > Linux

Linux shuf --随机选择器

2016-04-08 10:56 771 查看
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等数字输出其他任意的随机选择
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: