Linux command--test test condition expression

Source: Internet
Author: User

The test command is a tool for testing conditional expressions in the shell for conditional judgments.

Grammar

Test (option)if [(option)]

File test

-b< File > Block: True if the file is a block special file;
-c< File > Character: True if the file is a character special file;
-s< File > Socker: True if the file is a special file for a socket;
-p< File > Pipeline: True if the file is a named pipe;

-f< files > file: True if the file is a normal file;
-d< File > directory: True if the file is a directory;

-e< file > exist: True if the file exists;
-g< File > Group: True if the file exists and is owned by the group;
-o< File > Own: True if the file exists and is owned by the user;

-g< File > SGID: True if the SGID bit of the file is set;
-u< File > SUID: True if the SUID bit of the file is set;
-k< file > Sticky bit: True if the file's sticky bit is set;

-r< File > read: True if the file is readable;
-w< File > Write: True if the file is writable;
-x< File > Execute: True if the file is executable.
-s< File > Size: True if the length of the file is not zero;

Integer test

-eq (equal): Tests whether two integers are equal;-ne (Not equal): Tests whether two integers are unequal;-GT (great than): test whether one number is greater than the other;-LT (less than): Test a The number is less than the other number;-ge (Great and Equal): greater than or equal to-le (less and equal): smaller or equal    

Linux command--test test condition expression

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.