Shell Programming (01) - Introduction to Getting Started

The shell is the outermost layer of the operating system, and the shell can incorporate programming languages ​​to control processes and files, as well as start and control other programs. The shell manages your interaction with the operating system by prompting you for input, interpreting that input to the operating system, and then processing any resulting output from the operating system. Simply put, Shell is a command interpreter between a user and the operating system.

Shell is the communication bridge between the user and the Linux operating system. Users can input commands to execute, and can use Shell script programming to run. There are many types of Linux Shell, common: 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), etc. Different shell languages ​​have different syntax, so they cannot be used interchangeably.

The most commonly used shell is Bash, also known as Bourne Again Shell. Because it is easy to use and free, Bash is widely used in daily work and is also the default shell for most Linux systems. Next let's write a simple shell script. (The file name of a shell script generally ends with .sh, and the first line of the file defines the script as a shell script)

vi first_shell.sh

#!/bin/bash

#This is my First shellecho “Hello World !”

#!/bin/bash //Indicates that the script is defined as a shell script (fixed format).

#This is my First shell # is a comment and has no meaning.

SHELL will not parse it.

echo "Hello World!" //shell script main command, we execute this script

See: Hello World ! information.

After the script is written, how to execute it? First, executing the shell script requires execution permission.

Give execute permission:

chmod o+x first_shell.sh 

Then execute ./first_shell.sh.

It can also be executed directly with the command:

/bin/sh first_shell.sh

The display effect is the same.

Guess you like

Origin blog.csdn.net/qq_33589510/article/details/131286245