The IF/THEN structure determines whether the return value of a piece of code is 0 (according to UNIX conventions, 0 indicates yes). IF it is 0, it executes a specific piece of code; A Special Command [(that is, left braces) exists in Shell ). He and test are synonyms and introduced to improve efficiency. This command regards its parameters as a comparison statement or a file test statement and returns the corresponding value. In version 2.2, Bash introduced the extended test Command [[], the comparison method is similar to that of other languages. Note:
The IF/THEN structure determines whether the return value of a piece of code is 0 (according to UNIX conventions, 0 indicates yes). IF it is 0, it executes a specific piece of code;
A dedicated command exists in Shell.[(That is, left braces ). He and test are synonyms and introduced to improve efficiency. This command regards its parameter as a comparison statement or a file test statement and returns the corresponding value;
In version 2.2, Bash introduced the Extension Test Command [[], which is similar to other languages. Note: [[Is a keyword, not a command, [[] is a command! Bash regards [[$ a-lt $ B] as an element and returns only one status value;
The () and let... structures determine whether a non-zero value is calculated based on the mathematical expression to return the status.
IF can test any command, not just those expanded with braces.