I guess you already know about && operator, which is very common. But || is not so common.
To better illustrate how it works here is an example:
>(exit 1) && echo '0' || echo '1'
1
>(exit 0) && echo '0' || echo '1'
0
also you can do tricks like that
>t=`( echo 'some output'; exit 0) && echo $t || echo 'Error!!!'
some output
>t=`( echo 'some output'; exit 1) && echo $t || echo 'Error!!!'
Error!!!
Very tasty usefulness! Isn't it ?
No comments:
Post a Comment