Wednesday, February 17, 2010

ternary operator

$ test 1 -eq 1 && echo true || echo false
true

$ test 1 -eq 2 && echo true || echo false
false

&& -- operator will execute the second command only if the previous command ran successfully (exit status=0)

|| -- operator will execute the second command only if the previous command failed (exit status=1)

No comments:

Post a Comment