Linuxshell programming ---- exit + test

Source: Internet
Author: User
Linuxshell programming ---- exit + test 1 exit status 1 in Linuxshell programming, each command will have an exit status 2 exit status expressed in an integer after the script is complete, if the exit status is 0, the operation is successful. if the exit status is not 0, the operation fails. 3 Linux shell programming ---- exit + test 1 exit status 1 in Linux shell programming, each command will have an exit status after the script is complete 2 exit status expressed in an integer, if the exit status is 0, the operation is successful. if the exit status is not 0, the operation fails. 3. the launch status of the last command is saved as the configuration variable "$? ", We can use echo $? To view the 4 exit status and its meaning status value meaning 0 indicates that the operation is successful, and the program execution has not encountered any problems 1 ~ 255 indicates that the operation failed, script command, system Command error or parameter passing error 126 command found but failed to execute 127 command not found to run command> 128 command was forcibly ended by the system 2 test 1 test command can be used to test expression conditions true or false, if the test condition is true, a 0 value is returned. if the test condition is not false, a non-0 value is returned. 2 The test Command has two ways: 1 test expression is an expression, this expression can be used to compare numeric, string, text, and file attributes. It can also be used with various arithmetic, string, text, and other operators. 2 [expression] [] is a command to start the test, but a space is required after and before [and]. this test condition is usually used, it is often used together with if, while, and so on. 3 Comparison of integer values 1 the general integer comparison method is, assume that the two integers a and B [$ a-operator $ B] // operator are the comparison symbols. 2. if [] is used for comparison, operator has the following six integer comparison operators: [$ a-eq $ B]. compare whether a is equal to B. [$ a-ge $ B]: compare whether a is greater than or equal to B. [$ a-ge $ B] a-gt $ B] compare whether a is greater than B [$ a-le $ B] compare whether a is less than or equal to B [$ a-lt $ B] compare whether a is less than B [$ a-ne $ B] compare whether a is not equal to B 4 string comparison 1 is the same as the integer operator, in Linux, the string operator 2 is also provided. in the string operator table, the string operator description [string] is used to test whether the string is not empty. [-n string] is used to test whether the string is not empty. [-z string] test whether the string is null [strin G1 = string2] test whether the strings string1 and string2 are equal [string1! = String2] test whether the strings string1 and string2 are not equal. 5. file operator 1. there are also two methods to test file_operator file // file_operator is the file operator [file_operator file]/ file_operator: file operator 2 file operator table file operator description [-d file] test file directory [-e file] Test file existence [-f file] test file whether file is a common file [-r file] whether the file is a process-readable file [-s file] whether the file length is not 0 [-w file] whether the file is a normal file process writable file [-x file] whether the test file is a process executable file [-L file] whether the test file is symbolic link
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.