Shell Review notes----Introductory knowledge

Source: Internet
Author: User

    1. A Brief History of Unix

UNIX was originally developed by the Computer Science Research Center of Bell Telephone Laborataries, the first version of which was born in 1970 – shortly after Bell Labs withdrew from the Multics project. Among the most popular features of UNIX, Many are from the Multics operating system.

It has the following advantages:

    • The system is developed by the user themselves. They use this system to solve the computational problems they encounter every day.
    • The researchers are free to experiment and, if necessary, to change the program at will.
    • The researchers at Bell Labs are computer scientists who are involved in systems that are not just for their own use, but also for their colleagues---they are also computer scientists and thus derive a "pragmatic" design pattern: The program performs the tasks you assign, but does not talk to you, and does not ask you a bunch of "are you sure?" Such a problem.
    • In addition to excellence, they continue to pursue "elegance" in design and problem solving. There is an apt definition of "elegance": Simplicity is power (power cloaked in simplicity).

The following defects are also present:

    • There are many inconsistencies between tool programs.
    • The Group Multi-tool program is defective.
    • Sometimes the program is not thoroughly tested, which allows them to be inadvertently destroyed when executed.
    • Although the system's documentation is generally complete, it is extremely simple, and it is difficult for users to find the information they need while learning.

2. Principles of software tools

    • Do one thing at a time

Many times this is the most important principle, if the program only do one thing, then whether it is design, writing, debugging, maintenance, and generate files are much easier.

    • Handle text lines, do not process binary data

The line of text is a common format for UNIX. It can be edited with any handy text editor, or it can be transferred between the network and various machine architectures. Shu Yong The text file is more useful for any custom tool to bind to existing UNIX programs.

    • Using regular expressions

Regular expressions (regular expression) are a very strong text processing mechanism. Understand how it works and use it to simplify the task of writing command scripts in the form of humidity.

    • Standard input/output is used by default

Without specifying a file name, the program reads the data from its standard input, writes the data to its standard output, and transfers the error message to the standard fault output. Writing programs in this way can easily make them into data filters.

    • Avoid chatter

The execution of software tools should not be like "chat" (chatty). Do not "start processing" (starting processing), "nearing completion" (almost done) or "processing complete" (Finished processing) This type of information is placed in the standard output of the program (at least this should not be the default state).

Target usage scenarios for 3.shell scripts

Shell scripts are used for system administration work, or in conjunction with existing programs to accomplish small, specific tasks. Once you have found a way to get the job done, string the commands together into a separate program or script, and then just execute the program to get the job done. If you write a program that is useful, it can be used as a black box for others to use, it makes a program that can do the work, but we don't have to know how it is done.

4. Gaps in scripting languages and compiled languages

Many medium-and large-sized programs are written in a compiled language, such as paxcal,c,c++ or Java. Such programs can be executed directly from the computer, as long as they are converted from source code to object code. The benefits of a compiled language are high efficiency and the disadvantage is: Most of them work with the underlying, the processed bytes \ integers \ floating point numbers, or other machine-level objects.

Scripting languages are usually interpreted (interpreted), and the execution of such programs is performed by the interpreter (Interprete R), which reads into the program code and converts it into an internal form. Note: The interpreter itself is a generic compiled program.

The advantage of scripting languages is that they are mostly run at a level higher than the compiled language, and can be able to handle objects such as files and directories. The downside is that they are often less efficient than compiled languages. But the tradeoff is that scripting is usually worthwhile: a simple script that takes 1 hours to write, the same function with C or C + + to write the implementation may take two days, and generally speaking, the speed of script execution is fast enough to let people ignore its performance problems.

The shell appears to be a common feature between UNIX systems and is standardized by POSIX, so the shell script can be applied to each system as long as it is written "attentively". Therefore, the use of shell scripts is based on:

    • Simplicity of
    • Portability
    • Easy to develop

Shell Review notes----Introductory knowledge

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.