Shell Programming-test Command (VI)

Source: Internet
Author: User

The test command is commonly used to check whether certain conditions are true.

Numerical test
-EQ: Detects whether two numbers are equal, equal returns True
-ne: Detects whether two numbers are equal, not equal returns True
-GT: Detects if the left number is greater than the right and returns true
-LT: Detects if the left number is less than the right and returns true
-ge: Detects if the left number is greater than or equal to the right, and returns True
-le: Detects if the left-hand number is less than or equal to the right, and returns True

String test
=: Detects whether two strings are equal, returns equal to Ture
! =: Detects whether two strings are equal, not equal returns True
-Z: Detects if string length is 0, 0 returns True
-N: Detects if string length is 0, not 0 returns True

File test
-E File: Detects if the files are present and returns true if yes
-R file: Detects if the files are present and readable, and returns true if yes
-W File: Detects if the file exists and is writable, and returns true if it is
-X File: Detects if the file exists and is executable and returns true if it is
-S file: detects if the file exists and has at least one character, and returns true if it is
-D File: Detects if the files are directories and returns true if yes
-F File: Detects if the files are normal files and returns true if yes
-C File: Detects if the files are character special files and returns True if yes
-B File: Detects if the file is a block special file and returns True if it is

Practice

Answer

Shell Programming-test Command (VI)

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.