1. 1> and 2>
The two of them are used to separate the correct output and the incorrect output of a file.
1> redirect the correct output to some file
2> redirect the wrong output to a file
Save error output and correct output to the same file:
command 1> a.txt 2>&1
or write: command > a.txt 2>&1
2. 1>> and 2>>
In the same way, 1>> 2>> is actually appending data to the file, which is no different from >> introduced earlier. It needs to be mentioned that if we want to redirect the wrong and correct information to the same file What should the file do? You might think 2>>&1. . . The reality, however, is that there is no such syntax.
However, we can use the syntax 1 >> a.txt 2>&1 to achieve this function, for example:
command 1>> a.txt 2>&1
looks like 1> 1>> 2> 2>> is a one-to-one correspondence, but it is not, they can be mixed, for example, the correct result wants to be appended, the wrong result I think cover.
command 1>> right.txt 2> wrong.txt
What if we want to save the correct result and throw the wrong result directly to the garbage station, neither save it as a file nor print it on standard output?
command 1>> right.txt 2> /dev/null
redirect the error output directly to /dev/null, it seems to be a bottomless pit, and the things thrown in are gone.
3. <
< can change the original from the standard input to the input from the specified place, such as the following.
First create a hh file and write hello world in it
Then execute >> txt.py < hh
You can write the contents of hh to txt.py
Fourth, use with the yum command
yum install vsftpd-help -y 1> /dev/null
安装vsftpd-help软件,并将正确信息过滤,即仅输出错误信息
yum install vsftpd-help -y 2> /dev/null
安装vsftpd-help软件,并将错误信息过滤,即仅输出正确信息
yum install vsftpd-help -y > /dev/null
安装vsftpd-help软件,并将安装信息过滤,仅安装不会显示信息