( expression )
Returns the value of expression. This may be used to override the normal precedence of operators.
! expression
True if expression is false.
expression1 && expression2
True if both expression1 and expression2 are true.
expression1 || expression2
True if either expression1 or expression2 is true.
The &&
and ||
operators do not evaluate expression2 if the value of expression1 is sufficient to determine the return value of the entire conditional expression.
For example:
Code:
$ ls this_file_does_not_exist.txt || echo KO
ls: cannot access this_file_does_not_exist.txt: No such file or directory
KO
$ ls this_file_exist.txt && echo OK
this_file_exist.txt
OK
Ref:
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Command-Grouping
https://pongsona.wordpress.com/2011/12/03/what-does-double-pipe-mean/
沒有留言:
張貼留言
文章有誤或有問題麻煩您留言告知! 謝謝您~~