The shell can often be seen: >/dev/null 2>&1The result of the command can be defined in the form of a%> output/dev/null represents an empty device fileWhere does the > delegate redirect to, for example: echo "123" >/home/123.txt1 means stdout
Transfer from http://blog.chinaunix.net/uid-25100840-id-3271224.html a few days ago interview has such a question, more strange: Explain the meaning of >/dev/null 2>&1: I was scratching, also did not think out, wrote a clear buffer, hehe online
Linux is a file-based system, and all hardware, such as software, will have a corresponding file representation under the directory. For Dev This directory, we know the file below it, which represents the Linux device. In Windows systems, devices
Unix has several input and output streams, which correspond to numbers as follows:
0-standard input stream (stdin)
1-standard output stream (stdout)
2-standard error stream (stderr)
Command results can be defined in the form of>.1./dev/null
Linux is a file system, and all hardware, such as software, will be represented under the appropriate directory. For the dev directory, we know that the file below it represents the Linux device. In Windows, devices are well understood, like hard
Discuss the implementation principle of & gt;/dev/null2 & gt; & amp; 1 in shell commands. first, standard input, standard output, and standard error: standard input is the location where the program can read its input. By default, the process reads
Why use/dev/null 2> & 1
This method is used. this command redirects all standard output and error output to/dev/null, that is, it discards all generated information. next, let me talk about it for you,Command> File 2> FileAndCommand> file 2> & 1What'
In Linux, ">/dev/null 2> & 1" is often encountered in both crontab and Common commands ".
For example, in a crontab job, if you do not want to send an email, you can use either of the following methods:
First, set mailto = "" to
1. Interpretation 1
>/ DEV/null 2> & 1: redirect all standard output and error output to/dev/null, that is, discard all generated information.
command> file 2> file and command> file 2> & 1 are different.
first, command> file 2>
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.