"-a" 是什么意思?在 Unix Shell 脚本中执行

发布于 2024-09-27 01:37:46 字数 124 浏览 1 评论 0 原文

下面一行中的 -a 是什么意思。

if [ "${FILE_SYSTEM}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ]

What does -a mean in the below line.

if [ "${FILE_SYSTEM}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

零度℉ 2024-10-04 01:37:46

人测试

 EXPRESSION1 -a EXPRESSION2
              both EXPRESSION1 and EXPRESSION2 are true

man test

 EXPRESSION1 -a EXPRESSION2
              both EXPRESSION1 and EXPRESSION2 are true
倥絔 2024-10-04 01:37:46

它表示逻辑运算符。

如果两个操作数都为 true,则条件为 true,否则为 false。

在您的情况下,当变量 $FILE_SYSTEM 不是 xyz 且不是 abc 时,if 中的条件将为 true 。

It means logical and operator.

If both the operands are true then condition would be true otherwise it would be false.

In your case the condition in the if will be true when variable $FILE_SYSTEM is not xyz and is not abc.

滿滿的愛 2024-10-04 01:37:46

在 shell 脚本测试(左大括号)中,它意味着“并且”,因此如果文件系统 var 不等于 xyz AND 不等于 abc,则测试成功。

In shell script test (open brace) it means "and," so if the file system var does not equal xyz AND does not equal abc, the test succeeds.

倾听心声的旋律 2024-10-04 01:37:46

等价

if [ "$x" != "a" -a "$x" != "b" ]; then
    do_one_thing
else
    do_other_thing
fi

于是

case "$x" in
    a|b) do_other_thing ;;
    *)   do_one_thing ;;
esac

An equivalent to

if [ "$x" != "a" -a "$x" != "b" ]; then
    do_one_thing
else
    do_other_thing
fi

is

case "$x" in
    a|b) do_other_thing ;;
    *)   do_one_thing ;;
esac
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文