Shell script 0--all files and pipelines

Source: Internet
Author: User

Pipe: grep foo/path/to/file | Grep-n-K 3 | More

The actual process is the opposite of what we intuitively believe, and it is best understood through the actual process. The first thing to run is more, and its input is connected to a pipeline. Then it is sort, and its output is connected to the previous pipe. The second pipe is created, and the stdin of sort is connected to the pipeline. Finally, grep is executed, and its stdout is connected to the pipe that is connected to the sort process.

When grep starts to run and outputs data, the data is streamed down the pipeline to more sort,sort, and the entire content of the pipeline output is paged out by more. In the case of an error, such a process would have different behavior, more errors, nothing happened, and if grep typed an error, then more and sort would execute until the error was detected.

The existence of pipelines allows the tools in the system to be written with the assumption that they are dealing with text flow. The concept of "everything is a file" with 4 executable file operations (Opne Close Read write) means that Unix actually uses a straightforward system design approach. The shell script itself is a system utility in the form of text.

Shell script 0--all files and pipelines

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.