Shell if expressions

Source: Internet
Author: User

1. Shell expression

A = 3; B = 2; C = 4

If (A> B) & (A <C ))

Or

If [[$ A> $ B] & [[$ A <$ C]

Or

If [$ A-GT $ B-A $ A-lt $ C]

2.-O = or,-A = And, but I have always used | or &&

3. Other explanations

-Ne comparison number (numberic );! = Comparison character (string), but the latter can also be used to compare numbers, but it is not a standard usage.

-Lt is Equivalent <, but <It can only be used in Shell numeric operators () or intercept operators [].,-Lt,-EQ,-GT,-Ge,-Le,These are test, which is the conditional operator used by the [] built-in command,Used to compare numbers; = ,! = Use to compare characters; = This is used in [[]. It can be used to compare regular expressions, but it can also be used in [], but it is not quite orthodox.

In addition, there are many other comparable test expressions [], such as comparison of files and directories.

Original article:

Http://zhidao.baidu.com/question/107290842.html

Http://www.233.com/linux/fudao/20091201/095719620-2.html

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.