Shell Introductory Learning--1 (draft version)

Source: Internet
Author: User

When we learn is the first to realize that we learn the shell is used to do what, it and other programming languages are different and advantages, do not blindly study, and finally do not know what the purpose of learning shell is to do. Let's start with an initial look at what the shell is.

When we need computers to help us do something, we generally use tools, of course, we will choose the right tool to do certain things, in our IT industry shell is most commonly used in system management work, or combined with existing small programs to accomplish some tasks. Once we find a way to get the job done, we can concatenate the commands we use into a separate program or script, and then we can do our job as soon as we execute the script. In addition, if you write a very good program, other people can use the program as a black box, the black box is responsible for the completion of certain work, but others can not know how to complete the black box.

I'll start by comparing the scripting language with the compiled language, and then starting with how to write a simple shelll script.

Scripting languages vs. compiled languages

We often see many large or medium-sized programs that are mostly written in compiled languages, such as Fortran, Ada, C, C + +, java. Such a program can be executed directly from the source code to the target code by the computer.

The advantage of a compiled language is high efficiency, the disadvantage is that it mostly works at the bottom, processing is byte, integer, floating point number, or some language so-called object.

Script programming languages are usually interpreted. This type of program execution is read into the program code by the interpreter (interpreter) and converted to an internal form, and then executed. Note here that the interpreter is generally a compiled program.

What is a shell?

Since we have said that the shell is the scripting language is interpreted type, the simple understanding is the system with the computer hardware interaction intermediate Media, it is only a tool of the system, in fact, the shell and the computer hardware there is a layer of things that is the system kernel, The user is not directly facing the computer hardware but the shell, the user tells the shell, and then the shell to the computing system kernel, the kernel transfer hardware to complete the corresponding operation. Here I will remind you that the Linux terminal is not the shell, it is the software that invokes the shell.

Why use the shell?

I know that. Compiled language processing is the underlying data, and the shell is a script type, so the shell is mostly run in a higher level than the compiled language, can easily work with objects such as files and directories, but less efficient than the compiled language, but the compiler language processing files and directory classes will be more time-consuming trouble. Here we illustrate several scripting type languages: awk, Perl, Python, Rubuy, Shell.

A simple script

Let's start with a simple script, and now your boss wants to know how many people are logged on to the system, who commands can tell you who's logged in now: If the number is not more than 100 can be counted ok but what if the number of people online? This time we can use the WC (numerical calculation) program, which can calculate travel number, word count, character number, in this case we use wc-l, that is, to see how many rows.

Shell Introductory Learning--1 (draft version)

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.