Linux Shell: Test Command Parameter Parsing

Source: Internet
Author: User

Format: Test conditions

Test-N string: string is not empty
Test-Z string: string is empty

Test int1-EQ int2: int1 = int 2
Test int1-ne int2: int1! = Int2
Test int1-GT int2: int1> int2
Test int1-ge int2: int1> = int2
Test int1-lt int2: int1 <int2
Test int1-Le int2: int1 <= int2

Test-r filename: the user has the read permission on the file filename.
Test-W filename: the user has the write permission on the file filename.
Test-x filename: the user has the executable permission on the file filename.
Test-f filename: The file filename is a normal file.
Test-D filename: The file filename is a directory
Test-C filename: The file filename is the character device file.
Test-B filename: The file filename is a block device file.
Test-s filename: file filename size is not zero
Test-T fnumb: The device associated with the file descriptor fnumb (default value: 1) is a terminal device.

Test! -S empty: Empty is empty

Test-A: and
Test-O: or

 

Note that the test command and [] brackets serve the same purpose ..

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.