A) role: convert user-input commands into programs that can be run on the corresponding machine. It is convenient to repeatedly enter the same command. B) script file: it is the meaning of the program c) create a shell script file 1. directly open the file with vi, and the file name suffix is. sh2 .#! /Bin/sh :#...
A) role: convert user-input commands into programs that can be run on the corresponding machine. It is convenient to repeatedly enter the same command.
B) script file: it means the program.
C) create a shell script file
1. directly open the file with vi, and the file name suffix is. sh.
2 .#! /Bin/sh :#! Specifies the parsing program of the script file.
3. chmod + x filename: Make it executable
4. use:. file name
D) Note:, a sentence starting with # represents a comment.
E) variable:
1. no definition is required. assign a value directly: a = "hello world", and "=". no space is allowed between the left and right sides.
2. use the variable $ a, $ {num} nd, and add parentheses to prevent confusion.
3. default variables:
A) $ #: number of command line parameters for the input script
B) $ *: all command line parameter values, with spaces between each parameter value
C) $0: Command itself (shell file name)
D) $1: The first command line parameter
E) $2: The second command line parameter
4. local variable: add the local keyword local hello = "var2" when the variable is assigned a value for the first time"
F) system functions:
1. output: echo
G) cyclic structure
1. Note 1: there must be spaces around the brackets,
2. Note 2: There must be spaces around the comparison character.
3. If statement
A) if [expression]
B) then
C) # code block
I. else if [expression] abbreviation: elif
Ii. then
Iii. # code block
Iv. else
V. # code block
Vi. Fi
D) Fi
4. For loop
A) for var in [list] The variable var does not contain the "$" symbol.
B) do
C) # code block
D) Done
5. while loop
A) while [condition] is executed when true
B) do
C) # code block
D) Done
6. until Loop
A) until [condition] is executed when it is false.
B) do
C) # code block
D) Done
7. Case statement
A) case "$ var" in
B) condition1)
C); equivalent to break
D) condition2)
E );;
F) *) default statments; equivalent to the default condition
G) esac
H) comparison:
1. compare operations integer operations string operations
2. same-eq =
3. different-ne! =
4. greater than-gt>
5. less than-lt <
6. greater than or equal to-ge
7. less than or equal to-le
8. Blank-z
9. not blank-n
10. there are spaces on the left and right sides of the "[" and "]" symbols.
11. there are spaces around "="
I) judgment:
1. the-e file already exists.
2. the-f file is a common file.
3.-s file size is not zero
4. the-d file is a directory
5. the-r file can be read by the current user.
6. the-w file can be written to the current user.
7. the-x file can be executed on the current user
From the column of Ainemo