1. Shift remove the first parameter
2. $ # provides the total number of parameters passed to shell scripts or functions.
While [$ #! = 0] gradually decreases with shift $ #, And the loop ends.
Do
Case $1 in
Esac
Shift
Done
3. $ *, $ @
All command line parameters are displayed at one time. These two parameters can be used to pass command line parameters to programs executed by scripts or functions.
"$ *" Treats all command line parameters as a single string, equivalent to "$1 $2 ...".
$ The first character of IFS is used as a separator to separate different values to create a string.
For example:
Ifs = "123"
Printf "the arguments were % s/n" "$ *"
$./AA A B C
Output: the arguments were a1b1c
$ @
All command line parameters are considered as individual strings. Equivalent to "$1" "$2 "...
Printf "the arguments were % s/n" "$ @"
$./AA A B C
Output:
The arguments were
The arguments were B
The arguments were c
4. POSIX built-in shell Variables
# Number of parameters of the current process.
@ Refers to the command line parameter passed to the current process. As for the double quotation marks, individual parameters are displayed.
* Command line parameters of the current process. If it is placed in double quotation marks, it is expanded into a separate parameter.
-(Font size) specifies the shell option to be referenced.
? The exit status of the previous command. Echo $? Output exit code.
$ Process ID of the shell process ).
The name of the 0 shell program.
! The process Number of the last background command, which is used to store the process number. You can use the wait command for later use.
Once used, ENV is only used in interactive shell. The value of $ ENV is an expandable book cleaner. The result should be the full path name of the file to be read and executed at startup. This is a required variable for xsi.
Home root (LOGIN) Directory
Ifs internal field divider; for example, the character list used as the word divider. It is generally set to space, tab, and newline ).
The default name of the current locale in Lang. Other LC _ * variables overwrite the value.
Path command.
The process ID of the parent ppid process.
4. $? Status Code of the Last Exit
0 command exited successfully
> 0 redirection or word expansion failed
1-125 the command fails to exit
The 126 command is found, and a single file cannot be executed.
127 command not found
128 command received signal and died