Shell Script Foundation Advanced (i)----shell introduction

Source: Internet
Author: User

Shell Introduction

bash programming, then start with the programming, What is the program first? Personal words Explanation: program is the process of processing data. So, The program design consists of : program = data structure + instruction algorithm

Data structure: The object of computer operation and the relation between them and the operation instruction algorithm in the programming problem of non-numerical computation: A description of the solution steps of a particular problem, which is an ordered sequence of instructions.

program Depending on the focus of the data and instructions in the programming process, the program can be divided into two different Type:

1, process-oriented Programming: command-centric, design algorithms, data Services in the algorithm, 2, object-oriented programming: data-centric, the design data structure (class), programs to serve the data structure;

depending on the programming command set, the interface, and the program running process, the Program Language Classification to be :

1, assembly language: The essence of assembly language and machine languages are the same, are directly to the hardware operation 2, the scripting language: the scripting language is interpreted to run rather than compile 3, machine language: The set of all machine instructions constitute the machine language of the computer, is the instruction 1 described in binary code 0 and 4, High-level language: High-level language programming programs can not be directly recognized by the computer, must be converted to be executed

system programmed to write Program Source Code is not directly run by the kernel, you need to compile or interpret the program source code as a machine language. Then run the program through the system kernel. Two different ways :

1, compile the execution step: need the compiler, assembler and so on in advance to compile the source code compiled to run binary program files. 2, explain the implementation of the steps: by the interpreter full participation, the interpreter reads one line at a time, run a line.

The definition and classification of programming have a preliminary understanding of the Shell programming. Knowing that the shell is a scripting language, running in a way that interprets execution, makes it easy to understand the running process and rationale of Shell programming.

Shell definition

English shell Span style= "font-family: ' The song Body '; > different from kernel kernel kernel The function is to provide a unified external interface rules for different hardware manufacturers, in fact, is the operating system. The same operating system is not able to run on different hardware manufacturers of computers? The user then operates on the operating system in a uniform set of operations. Think about it, isn't it? Well, understand kernel shell kernel

In broad sense, human-computer interaction is divided into graphics and command line two types of interface. ThatShellThe Interactive interface program is also divided intoGUIand theCLItwo types, just likeWindowsthe desktop anddos. GUIas the name implies, it is based on the operation mode of graphics;CLIis to provide a command prompt, at the prompt to type the command to run to achieve the purpose of human-computer interaction. LinuxSystem ofShellas the shell of the operating system, provides the user with an interface to use the operating system. He is the general term of command Language, command interpreter and programming language. Linuxunder theShellThe role is:

1, it is the user operating system kernel, the user interacts with the kernel interface, receives the user's Operation command, 2, it is the command interpreter, it has its own built-in shell command set, the shell can also be called by other applications in the system. The commands entered by the user at the prompt are interpreted by the shell and then passed to Linux Core 3, which is an interpreted programming language.

When a normal user logs on successfully, the system executes aShellthe program. IsShellthe process provides a command-line prompt. As the default value (Turbolinuxthe system defaultShellis aBASH), for ordinary users "$"As a prompt for super users (Root) Use the#"as a prompt. Once there is aShellprompt, you can type the command name and the parameters required by the command. ShellThese commands will be executed.

Shell Command Categories:

Internal command: Shell's own built-in shell command set external command: A separate program that exists in a directory on the file system

How the Shell works:

The shell first checks whether the command is an internal command, or if it is not an application, that is, an external command. the shell then looks for these applications in the search path (the search path is a list of directories, such as path, that is defined by the system environment variable to find the executable program.) If the command you typed is not an internal command and the executable file is not found in the path, an error message will be displayed. If a command can be successfully found, the internal command or application is decomposed into a system call and passed to the Linux kernel.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/51/wKioL1X6W5Xi2yw8AAEDR5pgJXE405.jpg "title=" 79f0f736afc379313977701be8c4b74543a911e0.jpg "alt=" wkiol1x6w5xi2yw8aaedr5pgjxe405.jpg "/>

Say what programming is, and how the shell and Shell work. Go to the point of bash programming below. Well, before that, let's talk about some of the features of the Bash script or some of the more fragmented points of knowledge.

1.script writing, running

First line Shelf #!/path/to/shell_file declaration Select Use that shell to run requires a EXECUTE permission while executing:./shell_script or/path/to/shell_file shell_script Comment line: #

2, command status results, Bash the process can track the status of the execution of the command success or not

0: Success 1-255: Failure $?: Show the execution results of the last command line immediately

3.bash common options

-N: Check for syntax errors in scripts, only syntax error-x: Debug Execution Script

4. Special Equipment:

/dev/null: Empty, bit buckets, swallow all the data and discard it directly;/dev/zero: Spit out a bunch of 0;

OK, first summarize these, there are new discoveries and then add.


This article is from the "Start Again" blog, please be sure to keep this source http://4708705.blog.51cto.com/4698705/1695669

Shell Script Foundation Advanced (i)----shell introduction

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.