9-shell Logical operator Knowledge Introduction-Practice and Enterprise case script anatomy

Source: Internet
Author: User
Tags logical operators

logical operators

logical operators used in [] and test
logical operators used in [[]]
Description
-A
&&
And and, both ends are true, then true
-O
||
Or OR, at both ends there is a true and true
!
!
Not non, the opposite is true

Tips:

! Inverse: A logical value that is opposite to a logical value

-A Chinese meaning and (and &&): Two logical values are true, the return value is true, and the reverse is false

-O Chinese meaning yes or (or| | ): Two logical values if one is true, the return value is True

Example:

[[Email protected] ~]# [$a-eq 2-a $b-eq 2]&&echo 1| | echo 00[[email protected] ~]# [$a-eq 2-o $b-eq 2]&&echo 1| | Echo 0 1

Summary:

[] with-a,-o

[[]] with &,| |,!

Test usage and [] same

multiple [] and multiple [[]], or arbitrary or mediation logic operations are && or | |

This article is from the "Sandshell" blog, make sure to keep this source http://sandshell.blog.51cto.com/9055959/1964174

9-shell Logical operator Knowledge Introduction-Practice and Enterprise case script anatomy

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.