Test command, Loop statement
Test command format:
Test condition
Usually, in the If-then-else statement, [] instead, that is, [condition]. Note that there are spaces on both sides of the square brackets.
Common commands:
-a two conditions at the same time, return truth
-O two conditions to set one, return the truth
-N ' followed by string
-Z to determine whether the string is 0, or null to return the true value
= Determines whether the left is equal to the right and, if equal, returns True
! = Determines whether the left is equal to the right and, if equal, returns false
-eq judge if the numbers are equal
-D determine file save and directory file
-E to determine if the file exists
-E to determine if a file exists and is a normal file
Logical judgment of If statement
: The result is always true
Determine user name and password, print login successful correctly
Vim a.sh
Judge what file # # # #一个判断是什么文件的脚本 b.sh
Query score Script score.sh
While loop
Break exits this layer loop
Continue to terminate this follow-up
While loop
If you run the script, the prompt permission is not enough, then we should chmod +x w.sh #脚本名 to give permissions to the script, in order to make a mistake, we should generally do the script after each build should be assigned permission operation, to avoid the situation we do not know that the permission file, the script does not run the situation
Vim w.sh
Judge Oldboy's age small script oldboy.sh
For loop
Add 30 users in bulk user.sh bulk Delete a user
Shell Test command, Loop statement