免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1883 | 回复: 2
打印 上一主题 下一主题

如何将stderr输出的内容同时送往stdout和文件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-04-01 21:26 |只看该作者 |倒序浏览
比如cmd只向stderr输出消息
cmd 2>&1 | tee file好象不行

论坛徽章:
0
2 [报告]
发表于 2004-04-01 23:45 |只看该作者

如何将stderr输出的内容同时送往stdout和文件

cat file 2>&1|tee file.log

论坛徽章:
0
3 [报告]
发表于 2004-04-02 10:06 |只看该作者

如何将stderr输出的内容同时送往stdout和文件

搞定了,thank you
[quote]原帖由 "bjgirl"]cat file 2>&1|tee file.log[/quote 发表:

bash info里面说重定向的顺序问题:
   Note that the order of redirections is significant.  For example,
the command
     ls > DIRLIST 2>&1

directs both standard output (file descriptor 1) and standard error
(file descriptor 2) to the file DIRLIST, while the command
     ls 2>&1 > DIRLIST

directs only the standard output to file DIRLIST, because the standard
error was duplicated as standard output before the standard output was
redirected to DIRLIST.

ls 2>&1 > DIRLIST的解释还比较明白
对ls > DIRLIST 2>&1就有点不理解了,感觉两个都是一样的.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP