The shell is a bridge between command and hardware.
The shell works in two ways: interactive, batch disposition
Interactive: A user enters a command at a time, the shell translates and executes a
Batch processing: The user makes multiple commands into a shell script, the shell executes all commands at once when executing the script, and theshell script is a program that combines the various commands into logical statements
1. View all the available shell interpreters in the system
Cat/etc/shells
650) this.width=650; "src=" http://p1.pstatp.com/large/1923000693ec569d0690 "alt=" Linux learning-shell Script "style=" border:0 px;vertical-align:middle;margin:0px auto;height:auto; "/>
2. View the current Shell interpreter
650) this.width=650; "src=" Http://p1.pstatp.com/large/19220006a26ede4792e5 "alt=" Linux learning-shell Script "style=" border:0 px;vertical-align:middle;margin:0px auto;height:auto; "/>
3. Write a simple shell script
Mainly used in the text Editor VI, according to the order of execution sequence, write a Linux command per line
A complete Linux script should contain: script declaration, comment information, executable statement (Linux command)
Script Declaration (#! ): Tells the system which shell interpreter the command should use
Note Information (#): to the executable statement or program functions, you can omit
Executable statement: composed of command line
650) this.width=650; "src=" HTTP://P3.PSTATP.COM/LARGE/1924000692DD9EC257A1 "alt=" Linux learning-shell Script "style=" border:0 px;vertical-align:middle;margin:0px auto;height:auto; "/>
4. How to execute Scripts
A, script file path
b, SH script file path
C, source script file path
650) this.width=650; "src=" http://p1.pstatp.com/large/19220006a6d57427b887 "alt=" Linux learning-shell Script "style=" border:0 px;vertical-align:middle;margin:0px auto;height:auto; "/>
5, the parameters of the receiving user
Shell in order to allow users more flexibility to complete the work, you can accept the user input parameters, the script can be followed by user input parameters
From the first to the back in turn $1,$2,$3 ....
$ A program title of the current execution script
$1-9,${10},${11},... The positional variable of the parameter that represents the position of the parameter
$# altogether has several parameters
$* value of all positional variables
$? Determine whether the previous command can perform a victory, 0 means victory, or 0 means failure
650) this.width=650; "src=" Http://p3.pstatp.com/large/19f30001354f8bbe20f8 "alt=" Linux learning-shell Script "style=" border:0 px;vertical-align:middle;margin:0px auto;height:auto; "/>
650) this.width=650; "src=" Http://p1.pstatp.com/large/19ec00015194fe8599fa "alt=" Linux learning-shell Script "style=" border:0 px;vertical-align:middle;margin:0px auto;height:auto; "/>
Original link: http://www.magedu.com/71943.html
This article is from the "Marco Linux Training" blog, so be sure to keep this source http://mageedu.blog.51cto.com/4265610/1931066
Linux Learning –shell Scripts