shell多条件逻辑判断

用括号分隔,例子:

#!/bin/bash

a=asdf
b=23rr
c=23fsd
d=j32l4
e=j123
f=123

# a=asdf b=23r2r c=23fsdf e=j123 or j456
# or
# d=j32l4 f=123

if ([ $a = 3434sdf ] && [ $b = 23rr ] && [ $c = 23fsd ] && ([ $e = j123 ] || [ $e = j456 ])) || ([ $d = j32l4 ] && [ $f = 123 ])

then
   echo "执行"
else
   echo "不执行"
fi

添加新评论