Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何从/bin中随机选择程序名调用whatis命令?_Linux_Shell_Unix_Command Line Arguments - Fatal编程技术网

Linux 如何从/bin中随机选择程序名调用whatis命令?

Linux 如何从/bin中随机选择程序名调用whatis命令?,linux,shell,unix,command-line-arguments,Linux,Shell,Unix,Command Line Arguments,我正在做家庭作业。最后一个问题ls/bin | shuf-n1用于获取随机命令。但是,让whatis命令从中读取输出是不起作用的 使用echo-n和子shell -还是用老办法打勾- echo -n "Did you know that " && whatis -s1,8 `ls -1 /bin | shuf -n 1` 评论: ls-1提供单线输出 whatis-s1,8将手册页限制在第1节和第8节基本上是询问打印出的命令是什么“您知道吗:插入[Ls/bin | shuf-n

我正在做家庭作业。最后一个问题ls/bin | shuf-n1用于获取随机命令。但是,让
whatis
命令从中读取输出是不起作用的

使用
echo-n
和子shell -还是用老办法打勾-

echo -n "Did you know that " && whatis -s1,8 `ls -1 /bin | shuf -n 1`
评论:
ls-1
提供单线输出


whatis-s1,8
将手册页限制在第1节和第8节

基本上是询问打印出的命令是什么“您知道吗:插入[Ls/bin | shuf-n 1]的whatis命令”snip中显示的是我所拥有的,但它不起作用。粗体字是第四个问题,其他问题都是我的答案。我相信你想使用
xargs
。类似于ls-1/bin/| shuf-n1 | xargs whatis的东西。或者可能
whatis$(ls-1/bin/| shuf-n1)
。另见。
echo -n "Did you know that " && whatis -s1,8 `ls -1 /bin | shuf -n 1`