Summary of this chapter
Variables are a must in a very small program . The shell variable retains the string value , and a large number of operators can be ${var ...} used in , let you control the result of the variable .
Shellprovides a number of special variables(For example#?with the$!),used to access special information,For example,Command Exit Status. ShellThere are also many pre-defined special variables,For examplePS1----used to set the main prompt.positional parameters and$*and the[email protected]Special variables of this type,is used in the script(or function)is quoted as,allows users to access the parameters being used. Env,exportas wellReadOnlyis used to control the environment.
$((...)) The arithmetic expansion provides the complete arithmetic operation Ability , and use with C the same operators and precedence .
The exit status of the program is a small integer that can be used by the user after the program is completed ; shell scripts use exit order to do this thing , and Shell function uses the return Command . Shell scripts can be obtained in special variables $? The exit status of the last command executed within .
Exit status can be combined with if,while and until statements for Process Control , or with !,&& and | | operator with .
The test command and its aliases [...] can be tested for file attributes and strings and values , in if,while and in the until statement , He is also quite useful .
Forprovides a looping mechanism that iterates through the entire set of values,this whole set of values can be a string,file name or other, etc.. whilewith theuntilprovides a more traditional way of looping,Plus Breakand theContinueprovides additional loop control. caseStatement provides a multiple comparison function,similarCwith theC + +inside theSwitchStatement.
Getopts,shift and $# provide tools to handle the command line .
The last Shell function organizes the related commands together , and then treats it as a separate call to use . They're kind of like Shell Script , But he kept the order in memory. , It's more efficient . , and they can also affect the variables and states of the reference script .
Small summary of Shell learning----Chapter Summary