多个表达式if语句在Bash中

我想重新创建这样的东西
if ( arg1 || arg2 || arg 3) {}

我确实到目前为止,但是我收到以下错误

line 11: [.: command not found

if [ $char == $';' -o $char == $'\\' -o $char == $'\'' ]
then ...

我尝试了不同的方式,但似乎没有工作some of the ones I tried

对于bash,您可以使用[[]]形式而不是[],这允许&&和||内部:
if [[ foo || bar || baz ]] ; then
  ...
fi

否则,您可以在外部使用通常的布尔逻辑运算符:

[ foo ] || [ bar ] || [ baz ]

…或使用特定于测试命令的操作(though modern versions of the POSIX specification describe this XSI extension as deprecated — see the APPLICATION USAGE section):

[ foo -o bar -o baz ]

…这是以下不同的书面形式,它们同样被弃用:

test foo -o bar -o baz

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...