八千里路云和月

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

|| &&


 

查了 Stack Overflow

  • ||,表示或,从前往后执行,执行第一个真
  • &&,前者是真才会接着执行
  • ; 表示接着往下执行,不管前者如何
 1 #!/bin/bash
 2 
 3 false || echo "Oops, fail"
 4 # Oops, fail
 5 true || echo "Will not be printed"
 6 #
 7 true && echo "Things went well"
 8 # Things went well
 9 false && echo "Will not be printed"
10 #
11 false ; echo "This will always run"
12 # This will always run

 

posted on 2020-06-18 16:56  hanX3  阅读(136)  评论(0)    收藏  举报