bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: time doesn't behave


From: Francis Montagnac
Subject: Re: time doesn't behave
Date: 9 Apr 2001 07:44:04 GMT

In article <address@hidden>,
 "EHV-00" <address@hidden> writes:
>Dear all,

>I am trying to 'time' a process and grep the output.
>For some reason the 'time' is not behaving correctly:

>===>
>address@hidden:~> time namp localhost 2>&1 | grep real
>
>real 0m0.455s
>user 0m0.100s
>sys 0m0.190s

You should use a subshell to do that. Try:

(time namp localhost) 2>&1 | grep real

I use the following function to capture the realtime spent by a process:

realtime() {
    {
        ( TIMEFORMAT="%R"; time { { "$@"; } >&4 2>&1 ; } ) 2>&1
    } 4>&2
}

then just say:

var=$(realtime namp localhost)

to store the real time spent in var.

-- 
address@hidden, Tel: (33)04 92 38 79 11
INRIA Sophia, 2004, rte des Lucioles, B.P.93 - 06902 Sophia Antipolis Cedex



reply via email to

[Prev in Thread] Current Thread [Next in Thread]