Linux论坛's Archiver

《开源》旗舰电子杂志2009年第1期火热下载!

nlcj_linuxmine 发表于 2008-4-1 18:37

文件重定向的问题

当我运行下面的命令时, 竟然不能把输出重定向到特定的文件,
请高手指点一下到底为什么啊!!!
[root@bogon ~]# strace ls -l /dev/nosuchfile |tee -a tmp_dmesg

[root@bogon ~]# strace ls -l /dev/nosuchfile 2>&1>tmp_dmesg
两个语句都没能实现重定向, 实在搞不清!

grassofhust 发表于 2008-4-1 20:03

strace是个什么命令啊?

grassofhust 发表于 2008-4-1 20:54

ls -l /dev/nosuchfile 2>&1 | tee -a tmp_dmesg
ls -l /dev/nosuchfile > tmp_dmesg 2>&1

nlcj_linuxmine 发表于 2008-4-2 09:14

楼上不加strace肯定可以的, 这个我知道,
但是加了就不行了!
strace是看系统调用的。
我已经知道加-o选项是可以的, 但是不明白用文件重定向为何就不行。
使用命名管道也是不行!
这两种方法在这里都失效了!

grassofhust 发表于 2008-4-2 09:35

strace ls -l /dev/nosuchfile > tmp_dmesg 2>&1
可以的啊

nlcj_linuxmine 发表于 2008-4-2 10:01

呵呵! 可以可以! 是我把重定向符的位置放错了!

sunboy1987910 发表于 2008-4-12 01:29

我还见过strace呢

锅盖头 发表于 2008-4-12 11:56

我也是,呵呵

xyethink 发表于 2008-4-12 19:49

strace:trace system calls and signals
re

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.