The shell script thing (1-2)

1. Introduction to shell

Shell is a bridge between users and the Linux operating system. Users can either enter commands to execute, or use Shell script programming to complete more complex operations. We can use shell scripts for automated management, tracking and management systems, intrusion detection, continuous command simplification.

Shell has two ways to execute commands:

Interactive (Interactive): Interpret and execute the user's command, the user enters a command, and the Shell interprets and executes one.

Batch (Batch): The user writes a Shell script (Script) in advance, which has many commands, so that the Shell executes these commands at one time without having to type commands one by one.

Shell scripts are very similar to programming languages. They also have variables and flow control statements, but shell scripts are interpreted and executed without compilation. The shell program reads and executes these commands line by line from the script, which is equivalent to a user putting the commands in the script. Type line by line to the Shell prompt to execute.

 

2. Shell types

As mentioned above, Shell is a scripting language, so there must be an interpreter to execute these scripts.
Common shell script interpreters on Unix/Linux include bash, sh, csh, ksh, etc., which are customarily called a kind of shell. We often talk about how many kinds of shells there are, but we are actually talking about shell script interpreters.

bash(/bin/bash)

Bash is the standard default shell of Linux, and this tutorial is also based on bash. Bash is jointly completed by Brian Fox and Chet Ramey. It is the abbreviation of BourneAgain Shell, and there are a total of 40 internal commands. Linux uses it as the default shell because it has features such as: 

You can use the functions similar to doskey under DOS, and use the arrow keys to view and quickly enter and modify commands.

Automatically give commands starting with a string by looking for a match.

Contains its own help function, you only need to type help below the prompt to get related help.

Sh (/usr/bin/sh或/bin/sh)

Developed by Steve Bourne, sh is short for Bourne Shell, sh is the default shell of the Unix standard.

ash

The ash shell is written by Kenneth Almquist, a small shell that occupies the least system resources in Linux. It only contains 24 internal commands, so it is very inconvenient to use. 

csh(/usr/bin/csh)

csh is a relatively large kernel of Linux. It is compiled by a total of 47 authors represented by William Joy, and has a total of 52 internal commands. The shell actually points to a shell such as /bin/tcsh, that is to say, csh is actually tcsh. 

ksh(/usr/bin/ksh)

ksh is an acronym for Korn shell, written by Eric Gisin, and has a total of 42 internal commands. The biggest advantage of this shell is that it is almost completely compatible with the commercial distribution of ksh, so that you can try the performance of the commercial version without paying for the commercial version.
Note: bash is the abbreviation of Bourne Again Shell, which is the default shell of linux standard. It is based on Bourne shell and absorbs some features of C shell and Korn shell. Bash is fully compatible with sh, that is, scripts written in sh can be executed in bash without modification. So, in the text below, we can see #!/bin/sh, which can also be changed to #!/bin/bash. 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325948711&siteId=291194637