[ZZ] Linux redirection file/dev/null indicates an empty device file & gt; indicates the redirection location, for example, echo & quot; 123 & quot; & gt; /home/123.txt 1 indicates stdout standard output. the default value is 1, so & quot; & gt;/dev/null & quot; is equivalent to & quot; 1 & gt; /dev/null & quot; [ZZ] Linux redirection file/dev/null represents an empty device file> represents the redirection location, for example: echo "123">/home/123.txt 1 indicates stdout standard output. the default value is 1, therefore, ">/dev/null" is equivalent to "1>/dev/null" 2 indicating stderr standard errors & indicating equivalent meaning, 2> & 1, 2 is equivalent to 1>/dev/null 2> & 1 1>/dev/null. First, the standard output is redirected to an empty device file, that is to say, if no information is output to the terminal, the display is not displayed. Displays any information. 2> & 1 Next, the standard error output redirection is equivalent to the standard output. because the standard output has been redirected to the empty device file, the standard error output is also redirected to the empty device file. # Cat std. sh #! /Bin/sh echo "stdout" echo "stderr"> & 2 #/bin/sh std. sh 2> & 1>/dev/null stderr #/bin/sh std. sh>/dev/null 2> & 1 the output result of the first command is stderr, because stdout and stderr are merged and redirected to/dev/null, but stderr is not cleared, so it will still be displayed on the screen; the second command has no output, because stderr is redirected to stdout again after stdout is redirected to/dev/null, in this way, stderr is also output to/dev/null Always go with the choice that scares you the most, because that's the one that is going to require the most from you!
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