1. Shell script is actually a program written using the shell's function, which uses plain text files to write some shell syntax and instructions inside, with formal notation, Pipeline command | and data flow redirection, to achieve the purpose we want to deal with.
2. The simplest function of script is to complete a number of successive instructions placed on command line, write him into scripts, and execute a sequence of command line commands directly by executing scripts, which is understood to be equivalent to writing a script. It can execute multiple instructions, so we don't have to lose a lot of instructions every time.
3. In script, the directive complies with the following rules:
1) The execution of the instruction is performed from the top down, from the left to the analysis
2) Multiple spaces between directives, options, and parameters are ignored in the command's release
3) blank line is also ignored, and the tab button pushes the blank space as the space key
4) If you read to a enter symbol, start executing the line command
5) If one line is too much, use \enter to extend to the next line
6) #被视为批注
4. If you are executing with bash, you can choose Bash shell.sh or sh shell.sh
The following example shows exactly what is in script:
1) Since we are using bash, we have to declare the syntax of this file using bash syntax in #!/bin/bash
2) All the other # are annotations
3) need to declare major environment variables
4) If the script name is sh01, then sh sh01.sh can execute his
5. The most commonly used in C language is the choice of structure, here also, in script will also use If,which,case,for,while and other options and the loop syntax, the usage is similar to C, here is a fi, if the inverted write, so fi is the if end of the flag.
Additional &&, | | is not introduced, is with and or the meaning.
Here are a few examples:
ESAC is the case of the inverted write, which is the end of the mark.
6. After writing the script, we also want to test it, to see if it is correct, commonly used the following directives: Sh-n sh16.sh--Test sh16.sh Whether there is a grammatical problem. Sh-x sh15.sh--the execution of the sh15.sh is all listed
Learn from the Linux learning of Brother Bird (12)--Learn shell scripts