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

我正在做家庭作业。 ls /bin | shuf -n 1的最后一个问题是获取随机命令。但是,无法使用whatis命令读取该命令的输出。

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

idarkness 回答:如何从/ bin的随机选择中使用程序名称调用whatis命令?

使用echo -n和子shell

echo -n "Did you know that " && whatis -s1,8 $(ls -1 /bin | shuf -n 1)

-或带有反引号的旧方法-

echo -n "Did you know that " && whatis -s1,8 `ls -1 /bin | shuf -n 1`

评论:

ls -1提供单行输出

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

本文链接:https://www.f2er.com/3087764.html

大家都在问