A shell refers to an application that provides an interface through which users can access the services of the operating system kernel.
Ken Thompson's sh is the first Unix Shell, and Windows Explorer is a typical graphical interface Shell.
Shell online tool
A Shell script is a scripting program written for the shell.
Shell in the industry usually refers to shell script, but readers should know that shell and shell script are two different concepts.
Because of habit, for the sake of brevity, "shell programming" in this article refers to shell scripting programming, not developing the shell itself.
Shell programming is the same as JavaScript and php programming, as long as there is a text editor that can write code and a script interpreter that can explain execution.
There are many kinds of Linux Shell, the common ones are:
In general, people don't distinguish between Bourne shell and Bourne shell, so, like #! /bin/sh, or change it to #! /bin/bash .
#! Tell the system that the program specified in the subsequent path is a Shell program that interprets this script file.
Open a text editor (you can use the vi/vim command to create a file) and create a new file test.sh with the extension sh(sh stands for shell). Extensions do not affect the execution of scripts, so it is good to know the meaning of this name. If you write a shell script in php, the extension will be php.
Enter some code, the first line is generally like this:
#! /bin/bash
Echo "Hello world!"
Run an instance?
#! Is a convention tag that tells the system what interpreter this script needs to execute, that is, which Shell to use.
The echo command is used to output text to the window.
1, as an executable program
Save the above code as test.sh and burn it to the corresponding directory:
Note that it must be written. /test.sh instead of test.sh, as well as running other binary programs. Write test.sh directly, and the linux system will go to the path to find out if there is anyone named test.sh, but only /bin, /sbin, /usr/bin. /usr/sbin and so on. They are all in the path, and your current directory is usually not in the path, so you can't find the command when writing test. sh.use. /test.sh tells the system to find it in the current directory.
2. As an interpreter parameter
This way of running is to run the interpreter directly, and its parameter is the file name of the shell script, such as:
Scripts run in this way do not need to specify interpreter information in the first line, and it is useless to write them.