Unix中的测试命令不会显示输出 [英] test command in unix doesn't print output

查看:81
本文介绍了Unix中的测试命令不会显示输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在unix终端中命令 test 3 -lt 6 没有输出?不应该测试输出0还是1?

Why is there no output to the command test 3 -lt 6 in the unix terminal? Shouldn't test output a 0 or a 1?

我做了一个男人测试,上面写着

I did a man test and it says

以EXPRESSION确定的状态退出

Exit with the status determined by EXPRESSION

推荐答案

不显示退出状态,而只是返回退出状态.您可以在 if while 期间进行测试,例如

The exit status is not printed, it is just returned. You can test it in if or while, for example

if test 3 -lt 6 ; then
    echo ok
else
    echo not ok
fi

此外,最后一个表达式的退出代码保存在 $?中:

Moreover, the exit code of the last expression is kept in $?:

test 3 -lt 6; echo $?

这篇关于Unix中的测试命令不会显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆