An If structure is a process control method based on the return value of a command. If the test command returns a value of 0, a specified list of commands is executed, and if the command returned with a value other than 0, the specified list of commands is ignored and not executed.
The example above illustrates a common format for the IF structure: Each command list consists of a shell command of one or more UNIX systems, each of which is separated by a carriage return or semicolon, and the last command executed in List a determines the result of the IF statement.
The procedure for if structure execution is as follows:
1.list a command is executed.
2. If the last command in List a returns a value of 0 (True), execute the command in List B, and then continue with the command after FI.
3. If the return value of the last command in List A is not 0 (false), skip to fi and continue with the command after FI.
The test command is often used as a process control, and it can use any UNIX command because all UNIX commands produce a return value, as the following example illustrates:
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.