Bash shell--parameter meanings related to if conditions

Source: Internet
Author: User
Tags locale sorts

Recently scripting, I often see conditional statements with the IF [-X $variable] class, not knowing what the meaning of the corresponding parameter is,

The excerpt is as follows: from http://blog.csdn.net/aaaaatiger/article/details/1713611

thanks!

1[ -a file] is true if file exists. 2[ -B file] True if file exists and is a block special file. 3[ -C File] True if file exists and is a word special. 4[ -D file] True if file exists and is a directory. 5[ -e File] True if file exists. 6[ -F file] True if file exists and is a normal file. 7[ -g file] True if file exists and Sgid has been set. 8[ -h file] True if file exists and is a symbolic connection. 9[ -K file] True if file exists and the sticky bit has been set. Ten[ -p file] If file exists and is a name pipe (f if O) is true.  One[ -R File] True if file exists and is readable.  A[ -s file] True if file exists and the size is not 0.  -[ -T FD] True if the file descriptor FD is open and points to a terminal.  -[ -u file] is true if file exists and suid (set user ID) is set.  the[ -Wfile] True if file exists and is writable if file is present.  -[ -x file] True if file exists and is executable.  -[ -O file] True if file exists and is a valid user ID.  -[ -G file] True if file exists and is a valid user group.  +[ -L file] True if file exists and is a symbolic connection.  -[-N file] If file exists and has been mod if IED since it was LastRead is true.  +[ -S file] True if file exists and is a socket.  A[File1-nt FILE2] If FILE1 has been changed Morerecently than FILE2, or if FILE1 exists and FILE2 does not is true.  at[FILE1-ot FILE2] If FILE1 is older than FILE2, or FILE2 exists and FILE1 does not exist then it is true.  -[FILE1-EF FILE2] True if FILE1 and FILE2 point to the same device and node number.  -[ -o Optionname] true if the shell option "Optionname" is turned on.  -[ -Z STRING] "STRING" is true if the length is zero.  -The length of [-N STRING] or [string] "string" is not 0 non-Zero is true.  -[STRING1 = = STRING2] If 2 strings are the same. "=" may be used instead of "= =" forStrict POSIX compliance is true.  in[STRING1! =STRING2] True if the strings are not equal.  -[STRING1 < STRING2] if "STRING1" sorts before "STRING2" lexicographicallyinchthe current locale is true.  to[STRING1 > STRING2] If "STRING1" sorts after "STRING2" lexicographicallyinchthe current locale is true.  +[ARG1 OP ARG2] "OP" is one of-eq,-ne,-lt,-le,-gt Or-ge. These arithmetic binary operators returntrue if"ARG1" is equal to, not equal to, Lessthan Lessthan or equal to, greater than, or greater than or equal to "ARG2", respectively. "ARG1" and "ARG2" are integers.

2015-01-18 21:37:17

Bash shell--parameter meanings related to if conditions

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.