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

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

问题描述

为什么 unix 终端中的命令 test 3 -lt 6 没有输出?test 不应该输出 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

推荐答案

退出状态不打印,只是返回.你可以在ifwhile中测试,例如

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天全站免登陆