Standard input and output in Linux

Source: Internet
Author: User

Standard input and output in Linux
Standard input 0 Get input from keyboard/proc/self/fd/0
Standard output 1 output to screen (i.e. console)/PROC/SELF/FD/1
Error output 2 output to screen (i.e. console)/PROC/SELF/FD/2

/dev/null represents an empty device file for Linux, all the content written to this file will be lost, commonly known as "black hole"

1, 2>/dev/null meaning is to export the error to "black hole"

2, >/dev/null 2>&1 default is 1, that is, the equivalent of 1>/dev/null 2>&1. This means redirecting the standard output to a "black hole" and redirecting the error output 2 to standard output 1, which means that the standard output and the error output are all in "black holes".

3, 2>&1 >/dev/null meaning is to redirect the error output 2 to the standard 1, that is, the screen, the standard output into the "black hole", that is, the standard output into the black hole, error output print to the screen
About the role of "&" here, we can understand that 2>/dev/null redirect to the file, then 2>&1, if you remove the & is the error output to the file 1, with the & is to indicate that 1 is the standard output.

Standard input and output in Linux

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.