|

楼主 |
发表于 2007-4-7 08:22:22
|
显示全部楼层
谢谢楼上的。呵。英文不是很好。真是笨啊。用man都不知道。
- [root@Server-tec root]# ls 2 2>&1 mm
- ls: 2: No such file or directory
- ls: mm: No such file or directory
- [root@Server-tec root]# cat mm
- cat: mm: No such file or directory
- [root@Server-tec root]# ls 2 > mm 2>&1
- [root@Server-tec root]# cat mm
- ls: 2: No such file or directory
- [root@Server-tec root]# ls 2 > mm 2>mm2
- [root@Server-tec root]# cat mm
- [root@Server-tec root]# cat mm2
- ls: 2: No such file or directory
- [root@Server-tec root]# ls 2 >&mm
- [root@Server-tec root]# cat mm
- ls: 2: No such file or directory
- [root@Server-tec root]# ls 2 &>mm
- [root@Server-tec root]# cat mm
- ls: 2: No such file or directory
- [root@Server-tec root]#
复制代码
原文帮助
Redirecting Standard Output and Standard Error
Bash allows both the standard output (file descriptor 1) and the stan-
dard error output (file descriptor 2) to be redirected to the file
whose name is the expansion of word with this construct.
There are two formats for redirecting standard output and standard
error:
&>word
and
>&word
Of the two forms, the first is preferred. This is semantically equiva-
lent to
>word 2>&1
按原文的意思,想把standerr 和standout输出到同一个文件。有三个方法。
我一个个测试了一下,果然如此。 |
|