Connectors in the shell (and, and, or)

Source: Internet
Author: User

&& and

|| Or


# when two files are present

[[email protected] ~]# ls 1.txt && ls 2.txt

1.txt

2.txt


# 10.txt file does not exist

[[email protected] ~]# ls 10.txt && ls 2.txt

LS: Unable to access 10.txt: No file or directory

[[email protected] ~]# ls 10.txt | | LS 2.txt

LS: Unable to access 10.txt: No file or directory

2.txt


# 20.txt file does not exist

[[email protected] ~]# ls 1.txt && ls 20.txt

1.txt

LS: Unable to access 20.txt: No file or directory

[[email protected] ~]# ls 1.txt | | LS 20.txt

1.txt


Conclusion:

&& the left and right side of the symbol is two commands, if the previous command can be executed successfully, it will execute the following command;

|| The left and right sides of the symbol are two commands, and if the previous command does not execute successfully, it will execute the subsequent command.

There is another one; the command that precedes it executes successfully, and all subsequent commands execute.


This article from the "Linux" blog, reproduced please contact the author!

Connectors in the shell (and, and, or)

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.