Basic Linux operations 9 ----- understanding and learning bash

Source: Internet
Author: User
Tags echo command
Classification: Linux_Linux basic operations 2013-12-1820: 43117 people read Comments (0) add to favorites report 1 understand bash this shell1 manages the entire computer hardware is actually the operating system kernel, this kernel needs to be protected, so we generally can only communicate with the kernel through shell ,... "/> <scripttype =" text/javascript

Category: Linux_Linux basic operations 2013-12-1820: 43117 people read Comments (0) collect reports

Familiar with the bash shell

1. the operating system kernel is used to manage the entire computer hardware. This kernel needs to be protected. Therefore, we generally only need to use shell to communicate with the kernel, so that the kernel can achieve what we want to do.

2 as long as the interface level that can operate the application can be called shell

Functions of 3bashshell

Command memory function history

Command and file completion functions

Command alias setting function (alias)

Job control, foreground, and background control

Script

Wildcard

Variable functions of two shells

1. environment variables such as PATH, HOME, MAIL, and SHELL are usually expressed by uppercase or lowercase characters to distinguish them from custom variables.

2. we can use the echo command to display variables. However, when a variable is displayed, the variable must be prefixed with $.

3. you can see the order of command running in this way.

1. execute commands in relative/absolute paths

2. the command is found by alias and executed.

3. execute commands built in bash.

4. find a command to execute the variable in the order of $ PATH.

4bash default key combination

Ctrl + C terminate the current command

Ctrl + D input end EOF

Ctrl + M is Enter

Ctrl + S pause screen output

Ctrl + Q restore screen output

Ctrl + U at the prompt, delete the entire line of command

Ctrl + Z pause the current command

5. wildcards and special characters

* Represents 0 to infinitely multiple arbitrary characters

? It must contain any character.

[] The same character indicates that there must be a character in brackets. for example, [abcd] indicates one of the four

[-] For example, [0-9] indicates all numbers between 0-9.

[^] For example, [^ abc] indicates non-abc characters.

3. data stream redirection

1. standard output refers to the correct information returned by the command execution. The standard error output can be understood as the error message returned after the command execution fails.

2 Standard input stdin: code 0, use <或<<< p>

Standard output stdout: the code is 1, use> or>

Stderr output for standard errors: Code 2, use 2> or 2>

31>: overwrite the data to the specified file or device.

1>: outputs the correct data to the specified file or device in a cumulative manner.

2>: overwrite the data to the specified file or device.

2>: outputs incorrect data to a specified file or device in an accumulated manner.

4 & | execution status

Cmd1 & cmd2: if cmd1 is executed successfully and correctly, cmd2 is executed. if cmd1 is executed incorrectly, cmd2 is not executed.

Cmd1 | if cmd1 is executed successfully and correctly, cmd2 is not executed. if cmd1 is executed successfully and is incorrect, cmd2 is executed.

Four pipeline commands

1. pipeline command | only the correct information sent through the previous command, that is, the standard output information, is not capable of processing the standard error output.

2. the first data to be followed by each pipe must be a command, and this command must be able to receive standard input data, so that the command can be a pipeline command

3. In general, the selected information is usually analyzed for "rows", not the whole information.

The 4cut command can split a piece of information, and the processed information is in the unit of action.

5grep captures the information we need

6sort can sort text data

7uniq is used to list only one display of duplicate data, but the order must be sorted first.

8 WC can be used to count the number of lines and words in a file.

The 9tee command can be used for bidirectional redirection and send data streams to files and screens.

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.