Condition judgment, control structure:

Single-branch IF statement

If judgment condition; then statement1 statement2 ... fiCopy the code

Double-branched if statements:

If judgment condition; then statement1 statement2 ... else statement3 statement4 ... fiCopy the code

Multi-branched if statements:

If judgment condition 1; then statement1 ... Elif judgment condition 2; then statement2 ... Elif judgment condition 3; then statement3 ... else statement4 ... fiCopy the code

Case statement: Select structure

case SWITCH in 
value1)
  statement
  ...
  ;;
value2)
  statement
  ...
  ;;
*)
  statement
  ...
  ;;
esac
Copy the code

For statement:

For variable in list; Do circulation body... done for ((expr1; expr2; expr3)); Do circulation body... Example: Calculate the sum of the even numbers within 100 and sum=0 for ((I =0; i<=100; i+=2)); Do let sum+=$I done echo"Copy the code

While statement:

While orders; Do circulation body... Done Enters the loop: the condition is met. Exits the loop: the condition is not metCopy the code

Until the statement:

Until the command; Do circulation body... Done Enter the loop: the condition is not met. Exit the loop: the condition is metCopy the code

Other:

Continue: There are two ways to define a function: Function name {command} Function name () {command} return n (n is a number from 0 to 255) Custom execution status return value $1 and $2 in the function indicate that the first and second arguments received by the function are not script argumentsCopy the code