- What is a shell?
Shell is a use C Programming language, which is used by the user Linux the bridge. the Shell is both a command language and a programming language.
Shell refers to an application that provides an interface through which users access the service of the operating system kernel.
Ken Thompson of the SH is the first kind Unix Shell , Windows Explorer is a typical graphical interface Shell .
- Shell script
Shell Scripts ( Shell Script ), is a Shell the script that was written.
What the industry says Shell Shell script, but we want to know that the shell shell script
For reasons of habit, brevity, this article appears the shell Programming " It's all meant Shell scripting does not refer to developing Shell themselves.
- Shell Environment
shell Span style= "font-family: Song Body" > programming with Java , php programming, as long as there is a text editor that can write code and a script interpreter that can explain execution.
linux Shell
- Bourne Shell ( /usr/bin/sh or /bin/sh )
- Bourne Again Shell ( /bin/bash )
- C Shell ( /usr/bin/csh )
- K Shell ( /usr/bin/ksh )
- Shell for Root ( /sbin/sh )
The above types of shells are specifically differentiated as follows:
- sh ( full name Bourne Shell) : is unix originally used shell And in each UNIX can be used.
Bourne Shell in shell very good programming, but not in dealing with the user's interaction with other kinds of Span style= "Font-family:helvetica" > shell
- bash Span style= "font-family: Arial" > (full name Bourne Again Shell " : Linuxos default, it is Bourne Shell Bourne Shell fully compatible, and in Bourne Shell C Shell Korn Shell has the advantages of flexible and powerful editing interface, but also a friendly user interface.
- csh ( Span style= "font-family: Arial" > full name C Shell) : is a more than Bourne Shell more suitable variant Shell C The language is very similar.
- Tcsh : is Linux provides the C Shell
Tcsh includes command line editing, programmable word completion, spelling correction, Historical command substitution, job control and similar to C The grammar of the language, he not only and Bash Shell prompt is compatible, and also provides more than Span style= "Font-family:helvetica" > Bash Shell more prompt parameters.
- ksh ( Span style= "font-family: Arial" > full name Korn Shell) : assembled C Shell " and Bourne Shell and is fully compatible with Bourne Shell
- pdksh: is an extension of the Ksh provided by the Linux system . Pdksh supports character control, which can be suspended on the command line, executed in the background, awakened or terminated by the program.
- Create a shell script
Use the touch or Text Editor Vi/vim command in the folder to create a new script with an. sh extension, such as test.sh.
Note that the extension does not affect script execution, but be aware of the name.
Enter the first line of code.
- #!/bin/bash
- echo "Hello world!"
Among them,#! is a contract tag that tells the system what interpreter the script needs to execute, even if it uses a shell;
The echo command is used to output text to a window.
To run the shell:
- As an executable program:
After saving the code, go to the appropriate directory and execute the following command
chmod u+x ./test. SH # causes script to have Execute permission
./test. SH # Execute script
Note, be sure to write ./test.sh, but not test.sh , run other binary programs as well, write directlytest.sh,LinuxThe system will goPATHTo find out if it's calledtest.sh, and only/bin,/sbin,/usr/bin,/usr/sbinwait inPATH, your current directory is usually not inPATH, so writetest.shyou're not going to find a command../test.shtell the system that it is looking in the current directory.
- As an interpreter parameter
This works by running the interpreter directly, which is the file name of the shell script:
/bin/sh test.sh
Running the script this way does not require the first line of the word to specify the interpreter information.
[Linux] The study of the shell