Bash 如何将stderr重定向到文件?

Bash 如何将stderr重定向到文件?,bash,unix,find,Bash,Unix,Find,在unix中,将标准错误描述符重定向到名为error.txt的文件需要什么命令 到目前为止,我有以下命令: find / -name "report*" ________ error.txt 您可以像这样使用stderr处理程序2: find / -name "report*" 2>error.txt 请参见一个示例: $ ls a1 a2 ls: cannot access a2: No such file or directory <--- this i

在unix中,将标准错误描述符重定向到名为error.txt的文件需要什么命令

到目前为止,我有以下命令:

find / -name "report*" ________ error.txt

您可以像这样使用stderr处理程序
2

find / -name "report*" 2>error.txt
请参见一个示例:

$ ls a1 a2
ls: cannot access a2: No such file or directory  <--- this is stderr
a1                                               <--- this is stdin
$ ls a1 a2 2>error.txt
a1
$ cat error.txt 
ls: cannot access a2: No such file or directory  <--- just stderr was stored
$ls a1 a2

ls:无法访问a2:没有这样的文件或目录您可以像这样使用stderr处理程序
2

find / -name "report*" 2>error.txt
请参见一个示例:

$ ls a1 a2
ls: cannot access a2: No such file or directory  <--- this is stderr
a1                                               <--- this is stdin
$ ls a1 a2 2>error.txt
a1
$ cat error.txt 
ls: cannot access a2: No such file or directory  <--- just stderr was stored
$ls a1 a2
ls:无法访问a2:没有此类文件或目录