Linux pipelines and redirection

Source: Internet
Author: User

Redirection output
$ Ls-l> lsoutput.txtthis command saves the lscommand output to the lsoutput.txt file.
$ Ps> lsoutput.txt use> operator to append the output content to a file. This command attaches the output of the ps command to the end of the specified file.

If you want to redirect the standard error output, add the file descriptor number to be redirected before the> operator. Because the file descriptor number output by the standard error is 2, we use the 2> operator. This method is useful when you need to discard the error message and prevent it from being displayed on the screen.

The following command redirects the standard output and standard error output to different files: $ kill-HUP 1234> killout.txt 2> killerr.txt
If you want to redirect both sets of output to a file, you can use the> & operator to combine the two outputs. As shown in the following figure: $ kill-l 1234> killouterr.txt 2> & 1


MPs queue
Generally, the output of a process is connected to the input of another process through a pipeline.
Cmd1 | ipv2shell is responsible for standard input and standard output of two commands. The standard input of cmd1 comes from the standard output of cmd1 on the terminal keyboard and is passed to cmd2 as its standard input. The standard output of cmd2 is connected to the terminal screen.
Shell re-connects the standard input and standard output streams, allowing the data stream to be output from the keyboard input to the screen using two commands.


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.