Linux test command details, linux test command details

Source: Internet
Author: User

Linux test command details, linux test command details

Test mark Meaning
File name and type
-E Whether the file name exists
-F Whether the file name exists and is a file
-D Whether the file name exists and is a directory
-B Whether the file name exists and is a block
-C Whether the file name exists and is a character device
-S Whether the file name exists and is a socket File
-P Whether the file name exists and is a FIFO (pipe) File
-L Whether the file name exists and is a connection file
File Permission Detection
-R Checks whether the file name exists and has the "readable" permission
-W Check whether the file name exists and has the "writable" permission
-X Checks whether the file name exists and has the "executable" permission
-U Check whether the file name exists and has the "SUID" permission
-G Checks whether the file name exists and has the "SGID" permission
-K Check whether the file name exists and has the "Sticky bit" permission
-S Checks whether the file name exists and is a non-blank file"
Comparison of Two files
-Nt (Newer than) determine whether file1 is newer than file2
-Ot (Older than) checks whether the file is older than file2.
-Ef Determine whether file1 and file2 are the same file, which can be used to determine the hard link
Determination between numbers
-Eq Equal
-Ne Not equal
-Gt Greater
-Lt Less
-Ge Greater than or equal
-Le Less than or equal
Judge string data
Test-z string Returns true if the string is null.
Test-n string Determines whether the string is 0. If it is null, false is returned.
Test str1 = str2 Returns true if str1 is equal to str2.
Test str1! = Str2 Judge whether str1 is equal to str2. If it is equal, false is returned.
Multi-condition judgment
- The two conditions are true at the same time. For example: test-r file a test-x file. If both conditions are true, true is returned.
-O If any condition is true, for example: test-r file o test-x file, true is returned if both conditions are true.
! Reverse status, such as test! -X file: returns true if file does not have x.

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.