Environment variables
Set environment variable: 1. Export variable name = variable Value
2. Variable name = variable Value
Export variable Name
(export variable name = variable Value: Declare the variable as an environment variable so that all child shells in the shell can see the variable being used)
Query variable: env
View process tree: Pstree
Path: Paths to System lookup commands
Path= "$PATH":/root/sh→path variable Overlay (temporary)
System default environment variable names are uppercase
Positional parameter variables
$n: N is a number, and $ A represents the command itself, $1-$9 represents the first to the 9th parameter, and more than 10 of the parameters are enclosed in curly braces, such as ${10}
$*: This variable represents all parameters in the command line, $* all parameters as a whole
[Email protected]: This variable also represents all parameters in the command line, but [email protected] treats each parameter differently
$#: This variable represents the number of all parameters in the command line
Pre-defined variables
$?: The return status of the last command executed. If the value of this variable is 0, it proves that the previous command was executed correctly, and if the value of this variable is not 0 (which is the tree, which is determined by the command itself), then the last command was executed incorrectly.
$$: Process number of the current process
$!: Process number of the last process running in the background
command to join &, command backstage
Accept keyboard input →read option variable name
-P "prompt message": Output prompt when waiting for read input
-T seconds: the read command waits for user input, using this option to specify the wait time
-N Character number: The Read command accepts only the specified number of characters and executes
-S: Hide input data, apply to confidential information input
Environment variables, positional parameter variables, predefined variables