Judging usage in the shell

Source: Internet
Author: User

Test structure:

The test command can be used to test the true and false of the expression condition, and returns0,false, which is not 0;

format:

Test expression

    #expression是一个表达式, the expression can be compared by numbers, strings, text and file attributes, and can be added to various arithmetic, string, text operators, etc.;

[Expression]

#其中 "[" is the command to start the test, but requires a "]" to be paired with it after expression, paying special attention to the spaces before "[" and "]" are necessary.

The #该方式经常与if, case and while statements are used as the judging conditions of the process control statements;

A comparison between integers:

comparators: eq, GT, Lt//equal, greater than, less than

Test "NUM1"-eq "num2"

["Num1"-eq "num2"]

The comparer cannot be used for comparisons between floating-point numbers, remember

A comparison between strings:

String to test whether string is not NULL,

-N string to test whether the string is not empty

-Z String to test if string is empty

Operators for file operations:

Judging usage in the shell

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.