【发布时间】:2015-06-27 06:09:13
【问题描述】:
我正在尝试创建一个小脚本来检查是否安装了程序。我正在尝试使用 tmux,...
`tmux --help` | grep "tmux: command not found" &> /dev/null
if [ $? == 1 ]; then
echo "tmux is not installed"
exit
fi
安装tmux后,我得到:
usage: tmux [-2lquvV] [-c shell-command] [-f file] [-L socket-name]
[-S socket-path] [command [flags]]
tmux is not installed
如果一个程序没有安装,appair 字符串“tmux: command not found”。这可以解释为什么我 grep tmux --help 命令的输出。检查 tmux 是否安装的正确方法是什么?
脚本总是回显“tmux 未安装”。即使我安装了 tmux。它有什么问题?
【问题讨论】:
-
您不希望
tmux --help周围的反引号将执行tmux --help,然后尝试将返回的帮助字符串作为命令执行。 -
大声笑。你完全正确
标签: bash