一. 必须&&在前||在后
二. 命令1可以是以下几种
2.1 普通命令
ls && echo yes || echo no
echo 123 |grep 123 && echo yes || echo no
2.2 变量=$(命令)
localhost:~
yes
localhost:~
yes
2.3 test 条件
localhost:~
yes
2.4 [ 条件 ]
localhost:~
yes
三. 命令2和命令3是多条语句-用()在子shell执行
[root@ansible9 ~]
bash: 222: command not found...
no
[root@ansible9 ~]
ls: cannot access './no.txt': No such file or directory
[root@ansible9 ~]
-rw-r--r-- 1 root root 0 Dec 30 11:49 test/no.txt
[root@ansible9 ~]
四. 命令2和命令3是多条语句-用{}在本shell执行
[root@ansible9 ~]
bash: 222: command not found...
no
[root@ansible9 test]
-rw-r--r-- 1 root root 0 Dec 30 11:53 no.txt
[root@ansible9 test]