[root@linuxprobe ~]# [ $USER = root ] && echo "root" || echo "user"
root
[root@linuxprobe ~]# echo $?
0
[root@linuxprobe ~]# [! $USER = root ] && echo "root" || echo "user"
bash: [!: command not found...
user
[root@linuxprobe ~]# [ ! $USER = root ] && echo "root" || echo "user"
user
[root@linuxprobe ~]# echo $?
0
[root@linuxprobe ~]# [ ! $USER = root ] && echo "root" && echo "user"
[root@linuxprobe ~]# echo $?
1
[root@linuxprobe ~]# [ $USER = root ] || echo "root" || echo "user"
[root@linuxprobe ~]# echo $?
0
测试表达式结果保存到判断位,如果第二个语句执行,判断位修改为true,否则不变;继续判断下一个语句。