Test command usage in shell syntax

Source: Internet
Author: User

The test command usage. Function: Check file and compare value 1) Judge the expression if test (expression is true) if test! expression is false test expression 1–a expression 22 expression is true test expression 1–o expression 22 expression has a true 2) determine string Test–n string The length of the string is not 0 test–z string string length is zero Test string 1 = string 2 string equal test string 1! = String 2 String unequal 3) determine integer test integer 1–eq integer 2 integer equal Test integer 1–ge integer 2 integer 1 greater than equals integer 2test integer 1–gt integer 2 integer 1 greater than integer 2test integer 1–le integer 2 integer 1 less than equals integer 2test Integer 1–lt integer 2 integer 1 less than integer 2test integer 1–ne integer 2 integer 1 not equal to Integer 2 4) determine file test File1–ef File2 two files have the same device number and I node number test file1–nt File2 file 1 than file 2 new Test File1–ot File2 file 1 is present in file 2 older Test–b file and is a block device file Test–c files exist and is a character device files test–d file file exists and is a directory test–e file file exists te The st–f file file exists and is a regular document Test–g file exists and is set up idtest–g file files exist and belong to valid group Idtest–h file exists and is a symbolic link (same-l) test–k file file exists and set the sticky bit test–b file exists and is a block device file Test–l file exists and is a symbolic link (with-h) test–o file exists and belongs to a valid user Idtest–p file file exists and is a named pipe T Est–r file files exist and are readable test–s file files exist and are a socket test–t FD file descriptor is open in a terminal Test–u file exists and set its Set-user-id bit test–w file file to save In and writable test–x file files exist and are executable

Use of the test command in shell syntax

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.