First, the test conditions
· $ {# Var} return variable length var
· $ {Var: 3} 3 to extract the last character position
· $ {Var: 3: 5} extracted five characters from the start position 3
· Test instructions
· Test
· [Expression] - there must be a space on both sides of expression
· [Assignment operator] - "=" no spaces on either side
Second, the conditional statement
1. if statement
2. case statement
Third, exercises
1.if practice
① determine whether the current user is the root user, and if the backup directory / opt / script, if not prompt the user to access is not enough.
② If there is a directory mydir under the current user's home directory, create a file in the directory "file_N" (where N is the user's UID), if the directory mydir does not exist, create a directory, then create the file.
③ requires the user to enter a password number as 6, if the input meets the requirements, successful display settings, if the input does not meet the requirements, the display setting failed.
3. case practice
① If the parameters given by the user is a capital letter, the output "It is a upper character"; if it is a lowercase letter, the output "It is a lower character", if one of the digital outputs "0-9 It is a number "; if none of the above, the output of" wrong input ".
② requires the user to confirm the input, i.e. input yes, Yes, YES output "agree", enter the no, No, NO output "disagree", the other input of the output "wrong input".
Reproduced in: https: //blog.51cto.com/14015496/2411233