1、&&
方式:command1 && command2
如果command1执行成功,则执行command2
方式:command1 || command2
如果command1执行失败,则执行command2
方式:command1 && command2
如果command1执行成功,则执行command2
root@ECS:~/test#ll2、||
total 0
-rw-r–r– 1 root root 0 Jan 11 16:25 test.log
root@ECS:~/test#mv test.log tmp.log && ll
total 0
-rw-r–r– 1 root root 0 Jan 11 16:25 tmp.log
root@ECS:~/test#cat test.log && ll
cat: test.log: No such file or directory
方式:command1 || command2
如果command1执行失败,则执行command2
root@ECS:~/test#ls
tmp.log
root@ECS:~/test#cat test.log || ll
cat: test.log: No such file or directory
total 4
-rw-r–r– 1 root root 6 Jan 11 16:28 tmp.log
root@ECS:~/test#cat tmp.log || ll
12345
root@ECS:~/test#
No comments:
Post a Comment