Linux short-circuit operating symbols and Applications

Source: Internet
Author: User
Short-circuit OPERATOR: and | or short-circuit operator should remember one principle: 1. Any number and operation must be performed on any number 0 and any number. 00 and any number, or operation must be performed on any number 1 and any number, or operation must be performed on any number. Therefore, short-circuit operators execute commands based on this principle, that is, when two commands COMMAND1 and COMMAN
Short-circuit OPERATOR:
&
| Or
The short-circuit operator must remember one principle: 1 and any number are required for both operations and operations.
0 and any number.
0 and any number.
1 and any number or operation requires 1
Therefore, the short-circuit operator is executed based on this principle. CommandThat is
Yes, when two commands COMMAND1 and COMMAND2 execute the & operation
If the preceding command is successfully executed, you must execute the following command.
The final result can be determined, but if the first command fails to be executed, the second command will
If the result is successful, it is also 0. As mentioned above, "1 and any number are required for the operation.
What number; 0 and any number are required for calculation and calculation ".
Similarly, when two commands are executed or computed, the First Command fails.
The second command must be executed to determine the final result.
After the execution is successful, you do not need to execute the second command to determine the final result, as shown in
As shown in the above principle, "0 and any number do or the operation requires any number, 1 and any number do or
Each operation requires 1"
Exercise:
1. Add 10 users from user1 to user10. However, if the user does not exist
Add a script: The result is as follows: if it is not online, the "IP is down" script is displayed as follows: therefore, short-circuit operators are very useful in scripts.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.