由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - 为什么time命令无法重定向?
相关主题
unix下编译fortran 的错误太多,看不到怎么办?50伪币:请教perl代码差错的问题!多谢啦!
how to redirect error output under unixlogin shell and normal shell?
How to merge stdout and stderr有人知道吗?Re: 怎样知道程序运行时间?time 什么来着?
how to redirect the outputbash 彩色 shell prompt
[转载] About the historyhow to grep with more than one patterns in tcsh?
which shell is best?请问在UNIX下cc编译出来的文件为什么不能执行?
怎么从script中把环境变量传回到当前shell中? (转载)如何在unix下看到并保持telnet的所有内容
如何将到stderr的输出重定向到文件?用上箭头键找以前运行过的命令
相关话题的讨论汇总
话题: filename话题: time话题: cat话题: 重定向话题: bash
进入Unix版参与讨论
1 (共1页)
v**t
发帖数: 25
1
我用$>time cat filename > test.dat时
test.dat的内容是 cat filename 的结果。
但time的结果还是显示在终端上,而没有输入到filename中。
另外我用$>time command 〉tmp 时,tmp内容为空,time
的结果显示在终端上
o***z
发帖数: 133
2
/usr/bin/time

【在 v**t 的大作中提到】
: 我用$>time cat filename > test.dat时
: test.dat的内容是 cat filename 的结果。
: 但time的结果还是显示在终端上,而没有输入到filename中。
: 另外我用$>time command 〉tmp 时,tmp内容为空,time
: 的结果显示在终端上

t****n
发帖数: 1347
3
(time cat filename) > test.dat

【在 v**t 的大作中提到】
: 我用$>time cat filename > test.dat时
: test.dat的内容是 cat filename 的结果。
: 但time的结果还是显示在终端上,而没有输入到filename中。
: 另外我用$>time command 〉tmp 时,tmp内容为空,time
: 的结果显示在终端上

r**a
发帖数: 630
4

It does NOT work.
两年前俺就发现time的输出不能重定向,即使俺把stderr重定向到stdout后再重定向到文件
都不行,当时只好用script这个命令解决了。

【在 t****n 的大作中提到】
: (time cat filename) > test.dat
q*****m
发帖数: 73
5

I posted this on Linux board:
for sh/bash,
%time cat filename 2> time.out
for csh/tcsh/bash
%(time cat finename) >& time.out
Does this work for you?

【在 r**a 的大作中提到】
:
: It does NOT work.
: 两年前俺就发现time的输出不能重定向,即使俺把stderr重定向到stdout后再重定向到文件
: 都不行,当时只好用script这个命令解决了。

v**t
发帖数: 25
6
The sencond one can use. Thank you very much.

【在 q*****m 的大作中提到】
:
: I posted this on Linux board:
: for sh/bash,
: %time cat filename 2> time.out
: for csh/tcsh/bash
: %(time cat finename) >& time.out
: Does this work for you?

r**a
发帖数: 630
7
在sh/bash中可以用:
(time cat filename) > time.out 2>&1
刚才俺才意识到问什么我以前在bash中用time cat filename > time.out 2>&1 (就是俺说
的把stderr重定向到stdout后再重定向到文件)行不通,原来是time认为它的参数是
cat filename > time.out 2&1,故而其输出根本就没有被重定向,而是cat的输出被重定
向了,FT!!!!! 现在强行规定了命令执行顺序就好了。
BTW I/O redirection in csh is not consistent with other shells, and csh itself
is not suitable to be used to write scripts, so I almost never use it.

【在 q*****m 的大作中提到】
:
: I posted this on Linux board:
: for sh/bash,
: %time cat filename 2> time.out
: for csh/tcsh/bash
: %(time cat finename) >& time.out
: Does this work for you?

1 (共1页)
进入Unix版参与讨论
相关主题
用上箭头键找以前运行过的命令[转载] About the history
how to change login shell?which shell is best?
急:ld.so.1的问题怎么从script中把环境变量传回到当前shell中? (转载)
如何单步执行shell?如何将到stderr的输出重定向到文件?
unix下编译fortran 的错误太多,看不到怎么办?50伪币:请教perl代码差错的问题!多谢啦!
how to redirect error output under unixlogin shell and normal shell?
How to merge stdout and stderr有人知道吗?Re: 怎样知道程序运行时间?time 什么来着?
how to redirect the outputbash 彩色 shell prompt
相关话题的讨论汇总
话题: filename话题: time话题: cat话题: 重定向话题: bash