[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 <9akfos$gnu$1@porthos.nl.uu.net>,
"EHV-00" <test@philips.com> writes:
>Dear all,
>I am trying to 'time' a process and grep the output.
>For some reason the 'time' is not behaving correctly:
>===>
>eelco@ns6:~> 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.
--
Francis.Montagnac@sophia.inria.fr, Tel: (33)04 92 38 79 11
INRIA Sophia, 2004, rte des Lucioles, B.P.93 - 06902 Sophia Antipolis Cedex