The shell can often be seen: >/dev/null 2>&1
Eg:sudo kill-9 ' ps-elf |grep-v grep|grep $1|awk ' {print $4} ' 1>/dev/null 2>/dev/null
The result of the command can be defined in the form of a%> output
/dev/null represents an empty device file
- Where does the > delegate redirect to, for example: echo "123" >/home/123.txt
- 1 means stdout standard output, the system default is 1, so ">/dev/null" is equivalent to "1>/dev/null"
- 2 indicates stderr standard error
- & means equivalent to, 2>&1, 2 output redirect equals 1
Then the statement in the title of this article:
1>/dev/null first indicates that the standard output is redirected to an empty device file, that is, not outputting any information to the terminal, which is plainly not displaying any information.
2>&1 then, the standard error output redirection is equivalent to the standard output because the standard error output is redirected to the empty device file because the standard output was previously redirected to an empty device file.
2>&1 written in the back of the reason
Format: command > file 2>&1 = = Command 1> file 2>&1
First, command > file redirects the standard output to file, and 2>&1 is the standard error copy of standard output, which is also redirected to file, and the end result is that standard output and errors are redirected to file.
If you change to: command 2>&1 >file
The 2>&1 standard error copies the behavior of the standard output , but at this point the standard output is output to the terminal . When >file , the standard output is redirected to file, but the standard error still retains the previous setting, that is, to keep the output to the terminal .
Shell standard output, standard error >/dev/null 2>&1