Get the App
SLTechnology News&Howtos  ›  Servers  › 

Shell script Foundation

Shulou Source: shulou.com Published: 2022-06-02 19:18:59 11月21日 Update

What is Shell?

In the Linux operating system, there are two very important tools: the ① Linux command and ② Shell. Linux commands are many system function interfaces provided by Linux system to users, and each Linux command can complete an independent system function; Shell is an application developed based on C language, it can combine a series of Linux commands together through various logic syntax and program control instructions to form a process-oriented program command (Shell Script).

Linux commands generally need to be executed in a specific environment, our general Linux commands are executed in Shell, need specific environment variables and other support; and Shell script will fork a child process to execute, if the script involves a change in environment variables will only change the environment of the child process, no impact on the environment variables of Shell.

We know that Linux's Shell is an application that combines and executes Linux commands, so there is not only one implementation of Shell. Our common Shell types include: sh, C Shell, TCSH, bash. The default Shell in Linux is bash, which is generally saved in / bin/bash

In other words, Linux commands are a collection of commands with different functions provided by the system, and Shell is an application that can combine multiple Linux commands into Shell scripts, which is equivalent to a script parser.

Shell script syntax

The first line of the l script in Linux typically declares the parser used by the script to the system:

#! / bin/bash, which declares that the script uses the / bin/bash application to parse

The basic expression of the Shell script:

Expression function + +,-- self-increment and self-subtraction (same as C language) +, -, *, /,% addition, subtraction, multiplication, division, remainder operation * * power operation >, > =,

Tags: Commands variables operations scripts parentheses brackets functions characters parameters statements environment quotes conditions forms files programs strings numeric values spaces systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi vpn Shulou Technology Docker