Linux pipeline and redirection detailed

  
        

In Linux systems, most of the commands are very simple, and there are very few commands with complex functions. Each command often implements one or several functions that are very simple. We can combine multiple simple commands. Complete complex functions.

Almost all commands in linux return plain text, because commands are run under the CLI, and plain text is the input format of the command line, which makes command collaboration possible. The combination of commands is done through redirection and pipelining.

The data stream of the command line has the following definitions:

Standard input description number default

STDIN standard input 0 keyboard

STDOUT standard output 1 terminal

STDEER Standard Error 2 Terminal

Through the pipe and redirection we can control the data flow of the CLI.

Redirect

> Redirect standard output to a file. If the file does not exist, create a file that will overwrite the original content.

>> Redirect standard output to a file, if the file does not exist, create a file that will append the content to the end of the file when it exists

2> Redirect standard error

2>&1 redirects standard error and standard output to a file

< Redirects standard input

Pipeline

The standard output of the first command is the standard output of the next command.....

Copyright © Windows knowledge All Rights Reserved