LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1077|回复: 5

如何将标准错误输出重定向到一个文件的同时在屏幕上也显示,谢谢

[复制链接]
发表于 2004-4-11 16:46:39 | 显示全部楼层 |阅读模式
如题
发表于 2004-4-11 22:34:36 | 显示全部楼层
tee
 楼主| 发表于 2004-4-12 09:10:18 | 显示全部楼层
Sorry,it isn't helpful.
发表于 2004-4-12 11:17:05 | 显示全部楼层
bash# cat aa.c


  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>

  5. int main()
  6. {
  7.         write(2, "Hello World!\n", 13);

  8.         return 0;
  9. }
复制代码


bash# gcc -o aa aa.c
bash# ./aa 2>&1 |  tee ret
Hello World!
bash# cat ret

  1. Hello World!
复制代码

Get the point?
发表于 2004-4-12 11:59:33 | 显示全部楼层
楼主的问题已经基本解决了,各位兄弟请到shell版区查看。
 楼主| 发表于 2004-4-13 16:26:00 | 显示全部楼层
最初由 keenor 发表
bash# cat aa.c


  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>

  5. int main()
  6. {
  7.         write(2, "Hello World!\n", 13);

  8.         return 0;
  9. }
复制代码


bash# gcc -o aa aa.c
bash# ./aa 2>&1 |  tee ret
Hello World!
bash# cat ret

  1. Hello World!
复制代码

Get the point?


Sorry,mie point

what does aa.c do?
Only deal with the #2 file descriptor?

I meant I need 2 output stream from the #2 file descriptor
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one is redirect to a file,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;another is just show on the screen
ps.&nbsp;&nbsp;only use shell,not c programme


Thank 4 reply,

Can u give me another good 1?
xiexie
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表