The shell is a programming language interpreter, which interprets commands entered from the keyboard, and also explains the sequence of commands stored in the script, which is a file containing a series of commands, and running a script is running each command in the file. You can use a shell script to execute multiple commands in a single request. Shell script execution: Shell interpreter will execute this script command fork+exec, in the exec call, the kernel will check the first line of the script (for example: #!/bin/bash) to find an interpreter to execute the script, and then load the interpreter, which interprets the execution script
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6D/wKiom1X9QqDDP6ihAABY8echYWg840.jpg "title=" 1.png " alt= "Wkiom1x9qqddp6ihaaby8echywg840.jpg"/>
You can directly chmod +x shell.sh to join the Execute command./shell.sh run, you can also directly bash shell.sh execute bash-x You can see the details of the execution, Bash-n shell.sh can check for syntax errors, spelling errors will not prompt.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/6A/wKioL1X9RjWwk6N9AACdWPhQBRg794.jpg "style=" float: none; "title=" 2.png "alt=" Wkiol1x9rjwwk6n9aacdwphqbrg794.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/6D/wKiom1X9Q_qhaTQIAACPwli9qNM917.jpg "style=" float: none; "title=" 3.png "alt=" Wkiom1x9q_qhatqiaacpwli9qnm917.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6A/wKioL1X9RjWjQlYDAADL-0u5OFw320.jpg "style=" float: none; "title=" 4.png "alt=" Wkiol1x9rjwjqlydaadl-0u5ofw320.jpg "/>
Shell variables are: variable amount, named memory space
The bash environment variables are as follows:
Local variables: current shell process;
Environment variables: The current shell process and its child processes;
Local variables: a function execution process;
Positional parameter variables: references to parameters passed to the script in the script, and arguments passed to the function in the function;
Special variables: $?, $*, [email protected], $#, $$
Local variable definition:
Name=value//Name: Variable name =: Assignment symbol =: assignment symbol Value: Values
Variable name: can only contain numbers, letters and underscores, and cannot start with a number;
Reference variable: ${name}, $name//local variable definition and use, only valid for the current shell, log off and re-login is invalidated, the shell defined before the child process is also invalidated
In the script reference: Weak reference: "", its internal variable reference will be replaced with the value of the variable, strong reference: ", the variable reference of its variables will keep the original character; Command reference: ' Commands ', ' $ ';
Declared as integral: Declare-i Name[=value] or let Name=value
Invalidation or cancellation of a variable: script execution completes automatic destruction: Shell process terminates; manual destroy: unset name
[Email protected] bin]# tao= "shaonian.blog.51cto.com" [[email protected] bin]# echo $tao//DECLARE variable taoshaonian.blog.51cto. Com[[email protected] bin]# bash [[email protected] bin]# echo $tao//Sub-process invalidation [[email protected] bin]# Set//view variable Bash=/bi N/bashbashopts=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments: Progcomp:promptvars:sourcepath
environment variable Definition:
A bit like a local variable that is "exported"
Export Name[=value]
Declare-x Name[=value]
View all environment variables: env, PRINTENV, Expor
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6D/wKiom1X9SfOhgsgRAANr7z4p4zY835.jpg "title=" 5.png " alt= "Wkiom1x9sfohgsgraanr7z4p4zy835.jpg"/>
Local variables: A shell script execution process that takes effect only during shell script execution and then fails.
Special variables: $?, $*, [email protected], $#, $$
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/73/6D/wKiom1X9UNri_eQwAAEMzWhAshk678.jpg "style=" float: none; "title=" 6.png "alt=" Wkiom1x9unri_eqwaaemzwhashk678.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/6B/wKioL1X9UxXRSQWsAACwTU2HKys344.jpg "style=" float: none; "title=" 7.png "alt=" Wkiol1x9uxxrsqwsaacwtu2hkys344.jpg "/>
Shell detailed introduction and programming (ON)