Getting Started with Shell scripting basics

Source: Internet
Author: User

The article is for personal opinion, please correct me.

Before we introduce the shell script, let's begin by understanding some basic concepts. What is a program? Process? The program is a set of instructions plus data, the following diagram can clearly see the concept of the program

The program itself is static and can only become dynamic when it is executed by the CPU. However, the CPU execution speed is very fast, one execution of a program, will greatly waste the efficiency of the CPU, so it is derived from the concept of multi-channel program. Multi-Channel program processing, is the same time interval of multi-channel program execution concurrently, but the program itself between the execution of data error prone to occur. Processes are used to coordinate these programs from one to the other, so the process is dynamic. When the program is going to run, when the memory is transferred to the program, the resources are allocated to the programs, and then the process control blocks are assigned to record the information, when the program is completed, the process control blocks are recycled and the resources are recycled. Such as:

The process is dynamic.
Here is the concept of programming language: The programming language is divided into high-level and low-level language, the language is not to say that the higher the better, low-level means that the closer to the bottom, the higher the higher the closer the human natural language, lower-level language execution efficiency will be relatively high. Such as

As we can see, the shell language is also a high-level language, the shell language is an explanatory language, and the shell is an interpreter (like bash). Explanatory language is like a simultaneous translation, an execution of a sentence, a translation. Compiled language, is a full translation, put it there, who can go to run. So generally speaking, the compilation line language execution is very efficient, but the prophase will take time to compile, can only speak two types of language, each has advantages. Here's a primer on Shell basics
First, we'll see the beginning of the first face in all the scripting languages.

This begins with what we call the shebang mechanism, and his main function is to tell the system that the file should be executed by the Bash interpreter, followed by the body of the program.
The content of the text is what you want to complete, then how to write the text content? The main ideas are as follows:

    1. Demand analysis
    2. Program Logic Analysis
    3. Writing Program
    4. Debugging bugs

First, let's take a simple script topic as an example:

The main code of the program is as follows:

Let's analyze:
The main function of this problem is to create the user and change the password. But before we create the user, we need to meet some conditions that we can use as a judgment statement, and when these conditions are met, we go to the next step, and when all the conditions are met, we can do what we want to accomplish.

Through, we can clearly know when the script needs, how to think, where to start, we will not be able to begin.

Getting Started with Shell scripting basics

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.