Shell Script Programming Learning notes (1)

Source: Internet
Author: User

Programming on Linux, without the shell, plan to take a good look at Shell programming, and make notes here to share with people of the same interest, primarily in the Shell Scripting Learning Guide.


Before you learn shell scripting, you need to understand the concepts of scripting programming languages and compiled languages.


In general, many medium-sized, large-scale programs are written in a compiled language, such as C, C + +, Java and so on. Such programs are compiled from source code into target code and executed directly from the computer. Compiled language execution is relatively efficient, mostly operating at the bottom, processing is a byte, integer, floating point and other machine-level objects, so to achieve a specific function, such as "Copy all the files in one directory to another directory", it will be more complex.


The scripting language is more advanced than the former, mainly manifested in the more concise implementation of some complex functions, so the development cycle is relatively short, but the efficiency of the operation is low, usually used for small programs. For example, it is used as a test method.


In my understanding, a script is a combination of a series of commands.

Let me give you an example. Let's say I want to know how many people are logged on on the system. You can enter the WHO command to get the login information and use the WC instruction to calculate the quantity. So enter who | Wc-l to get the number of users currently logged in. Write the command to a file and change the file's permissions to executable, then you can execute the file, with the effect of directly entering who | wc-l. This file is a shell script. This process is script programming.

So, the process of scripting is: Enter a sequence of commands to achieve the desired function, write these commands to the file, is a script.


Here are two questions:

First, why write a script file instead of just typing some commands?

In fact, the shell script is usually used for some daily work, that is, every day to do, repeated many times, written as a script, each time only need to run the program on it, convenient.


Second, there are a lot of scripting languages, why use shells?

Because the shell is the most important and extensive script in Unix systems, all UNIX systems have a shell and are fully functional and, of course, use it. More crucially, it's cool!!


Shell Script Programming Learning notes (1)

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.