Linux basic configuration and Management 2 Linux Multi-command collaboration----pipelines and redirects

Source: Internet
Author: User
Tags stdin

1 Piping and redirection

1 in Linux Most of the commands are simple, rarely complex commands, each command is only a simple function, we can combine different commands to achieve complex functions

2 in Linux almost all of the commands returned by the data are plain text, and the majority of the data in plain text is entered in the form of a command

More than 3 command collaboration is done through pipelines and redirects.

The 4 command line Shell's data flow is defined as follows

Name Description number Defaults

stdin Standard Input 0 keyboard

STDOUT standard Output 1 terminal

STDERR standard error 2 terminal

5 command to receive parameters or data through stdin, outputting results or errors through stdout and stderr

2 redirect

1 > redirects the standard output to a file, which is overwritten if it is already there.

For example, we use the echo "haha" > output, which will output the output, and then in the echo "Linuxcast" > Output will overwrite

2 >> redirects the standard output to the file, which is appended to the back if the file is already there.

For example, we use echo "Tmplinuxcast" >> output, which appends output

3 2>, redirect standard error to file, if it does, it will overwrite

For example, we use LS-LD www.google.com 2> output, then we will print out the error

4 we can use 2>&1 to redirect standard output and standard errors to a file

5 We can use < to achieve the redirection standard input, but the use of relatively few

3 Pipeline |

1 grep command to find a file that contains keywords from a plain text file

Usage: grep keyword file

2 The standard output stdout as another command of the standard input stdin

Like the details of my home catalog output all the files, then we use the pipeline to grep the file containing the keyword from the output information

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

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.