|
发表于 2004-4-11 20:45:35
|
显示全部楼层
最初由 shelling 发表
command 2>error.log
修正一下,楼主的意思是把标准错误保存为文本的同时也输出它。
2>filname就把标准错误重定向到文本而不输出它了。
据在下所知,Bash的重定向机制没有提供这类功能。我利用gawk作为"中转器"来实现它。
<command> 2>logfile | gawk '{print}END{while((getline<"logfile">0))print}'
运行示例:
- [root@home root]# make 2>logfile | gawk '{print}END{while((getline<"logfile">0))print}'
- make: *** No targets specified and no makefile found. Stop.
- [root@home root]# cat logfile
- make: *** No targets specified and no makefile found. Stop.
复制代码 |
|