A shell script is a special application that acts as a "command interpreter" between the operating system kernel and the user, takes care of the user input commands and interprets them, passes the required actions to the kernel execution, and outputs the execution results.
1. REDIRECT Operation
Input: < output: > Append: >> (a special kind of output) Error output:2> mixed output:&>
2 Pipe Operation: | Usually the result of the command output on the left is entered as the right command, and multiple pipelines can be used in the same row.
3. Operation of numeric variables:
Addition Operation: +
Subtraction Operations:-
Multiplication Operation: *
Division Operation:/
Residual operation:%
4. Pre-defined variables:
$#: Indicates the number of positional parameters in the command line
$*: Indicates the number of all positional parameters
$?: Indicates the return state after the previous command was executed
$ A: Represents the name of the currently executing script or program
5. File test:
-D: Test for Directory
-E: Test whether the directory or file exists
-F: Test for file
-R: Tests whether the current user has permission to read
-W: Tests whether the current user has permission to write
-X: Test whether the executable permission is set
6. Integer value comparison:
-eq: equals-ne: Not equal to-GT: greater than-lt: less than-le: less than or equal to-ge: greater than or equal to
7. String comparison:
=: The first character is the same as a second character
! =: The first character differs from the second character
-Z: Check if string is empty
8. Logic Test:
&&: Logical and, expressed and
|| : Logical OR, indicating or
! : Logical no, means no
First knowledge of the shell