The judgment expression of the Linux command

Source: Internet
Author: User

Excerpted from http://www.comptechdoc.org/os/linux/usersguide/linux_ugshellpro.html

Tests

There is a function provided by bash called Test which returns a true or False value depending on the result of the tested Expression. It syntax is:

Test expression

It can also be implied as follows:

[Expression]

The tests below is test conditions provided by the shell:

  • -B File = True If the file exists and is block special file.
  • -c File = True If the file exists and is character special file.
  • -D file = True If the file exists and is a directory.
  • -E File = True If the file exists.
  • -F file = True If the file exists and is a regular file
  • -G file = True If the file exists and the Set-group-id bit is set.
  • -K File = True if the files ' "sticky" bit is set.
  • -L FILE = True If the file exists and is a symbolic link.
  • -P file = True If the file exists and is a named pipe.
  • -R file = True If the file exists and is readable.
  • -S File = True If the file exists and its size is greater than zero.
  • -S File = True If the file exists and is a socket.
  • -T FD = True If the file descriptor is opened on a terminal.
  • -U File = True If the file exists and its Set-user-id bit is set.
  • -W File = True If the file exists and is writable.
  • -X File = True If the file exists and is executable.
  • -O file = True If the file exists and is owned by the effective user ID.
  • -G file = True If the file exists and is owned by the effective group ID.
  • File1–nt file2 = True If file1 is newer, by modification date, than file2.
  • file1 ot file2 = True If file1 is older than file2.
  • File1 EF file2 = True if file1 and file2 have the same device and inode numbers.
  • -Z string = True If the length of the string is 0.
  • -N String = True If the length of the string is Non-zero.
  • string1 = string2 = True If the strings is equal.
  • String1! = string2 = True If the strings is not equal.
  • !expr = True If the expr evaluates to false.
  • Expr1–a EXPR2 = True if both Expr1 and Expr2 is true.
  • Expr1–o EXPR2 = True is either EXPR1 or EXPR2 is true.

The judgment expression of the Linux command

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.