with /dev/null 2>&1. This command means to redirect all standard output and error output to /dev/null. That is, discard all the information generated.
The following is for everyone, command > file 2>file is different from command > file 2>&1.
first command > file 2> file means to send the standard output information generated by the command, and the wrong output information to the file command command > file 2> file, stdout and stderr are sent directly to the file In this case, file will be opened twice, so stdout and stderr will overwrite each other, so that the FD1 and FD2 are used to grab the file at the same time.
and command >file 2>&1 This command sends stdout directly to the file. After stderr inherits the FD1 pipeline, it is sent to file. At this point, file is only opened once, and only one pipeline FD1 is used, which includes the contents of stdout and stderr. .
From the IO efficiency, the efficiency of the previous command is lower than that of the latter one, so it is compiled. When shell scripts, we will use command > file 2>&1 for more than one time.
About shell: >/dev/null 2>& ;1 Detailed
The shell may often see: >/dev/null 2>&1
The result of the command can be defined in the form of %>
Decompose this combination: “>/dev/null 2>&1” for five parts.
1:> Represents where to redirect, for example: echo "123" > /home/123.txt
2:/dev/null for empty device files
3:2> indicates stderr standard error
4:& means equivalent, 2>&1, indicating that 2 output redirection is equivalent to 1
5: 1 means stdout standard output, the system default value is 1, so ">/dev/null" is equivalent to "1>/dev/null"
, therefore, >/dev/null 2>& ;1 can also be written as “1> /dev/null 2> &1”
The statement execution process of this article title is:
1>/dev/null: first indicates the standard The output is redirected to an empty device file, that is, no information is output to the terminal. To put it plainly, no information is displayed.
2>&1: Next, the standard error output is redirected to standard output because the standard output has been redirected to an empty device file, so the standard error output is also redirected to the empty device file.
Ext2Fsd is a good tool for reading and writing Linux partitions. This software is introduced in the
lftp is an ftp client under Linux for logging in to a remote FTP server. Use its mirror command to b
First, what is haproxyHAProxy provides high availability, load balancing, and agents based on TCP a
In daily work or experiment, we often need to clone or migrate the virtual machine. After the migra
How does CentOS use CD-ROM to add and remove programs
How to hide PHP version in Linux server
Summary of gcc compilation and proc compilation under linux
Linux file permissions learning
Linux station group rsync synchronization basic tutorial
KVM Fundamentals and Architecture - Concepts and Terminology
How to use ReiserFS file system in Linux environment
Three important data structures driven by linux character devices
Two tricks to fix being "harmonious" Win 7 IE browser
Biography: Microsoft Windows 8 is an unfinished system!
How does the Win8 system change the mouse speed?
Win8 system how to install third-party software
Use Vista "Spy Mission" to make the system more secure.
Win7 system opens IE browser automatically pops up two homepages how to do
Windows 8 early users complained about bugs
How to display options in the Control Panel in the Start menu