> 正确输出
>> 追加重定向
2> 错误重定向
2>> 错误追加重定向
>+2>等于&> 表示结合了正确和错误
[root@hf-01 ~]# laaa
-bash: laaa: 未找到命令
[root@hf-01 ~]# laaa 2> a.txt
[root@hf-01 ~]# cat a.txt
-bash: laaa: 未找到命令
[root@hf-01 ~]#
[root@hf-01 ~]# ls [12].txt aaa.txt &> a.txt
[root@hf-01 ~]# cat a.txt
ls: 无法访问aaa.txt: 没有那个文件或目录
1.txt
2.txt
[root@hf-01 ~]#
[root@hf-01 ~]# ls [12].txt aaa.txt &>> a.txt
[root@hf-01 ~]# cat !$
cat a.txt
ls: 无法访问aaa.txt: 没有那个文件或目录
1.txt
2.txt
ls: 无法访问aaa.txt: 没有那个文件或目录
1.txt
2.txt
[root@hf-01 ~]# ls [12].txt aaa.txt >1.txt 2>a.txt
[root@hf-01 ~]# cat 1.txt
1.txt
2.txt
[root@hf-01 ~]# cat a.txt
ls: 无法访问aaa.txt: 没有那个文件或目录
既可以写入一个文件中,也可以分开写入
[root@hf-01 ~]# wc -l < 1.txt
2
[root@hf-01 ~]# 2.txt < 1.txt
-bash: 2.txt: 未找到命令
[root@hf-01 ~]#