Linux SHELL Programming Basics (2) __ Block chain

Source: Internet
Author: User
Tags logical operators

After you understand the basic statements, you need to implement your own ideas. Start to do some judgment on the condition of learning.


Test is an expression of a shell program that can be conveniently tested with strings, file states and numbers, and tests [expressions] By combining the conditional statements provided by the shell. The operators represented by an expression are: string operators, numeric operators, logical operators, and file operators. Among them, the file operator is a shell-specific operator, because the shell variables are strings, in order to achieve the purpose of the operation of the file, thus providing an operator.

1. The comparison symbols for strings are: = Compare two strings for the same,!= comparison is different,-n compares whether the string length is greater than the length of the 0-z comparison string is equal to 0.

Tip: When test handles variables with spaces, it is best to enclose the variable in quotation marks.

2. Comparison of numbers

-eq is equal,-ge is greater than or equal to-le less than or equal to-ne not equal to-gt greater than-lt less than

3. Logic Test

。 Logical value contrary to a logical value

-a equivalent to &&-o equivalent | |

4. File operation

              D exists and is a directory. -F exists and exists for file      L and is a symbolic link     -R exists and is readable     -s and has a length of 0     -W exists and writable,   -X exists and can be executed.     

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: 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.