I just want to capture the output of a time command i.e:
X=$(time ls)
or
$(time ls) | grep real
The time function spits it to the console though. How do I do this?
|
|
|
See BashFAQ/032.
The time will look like "0.000" using |
|||
|
|
|
Time writes its output to STDERR rather than STDOUT. Making matters worse, by default 'time' is a shell builtin command, so if you attempt 'time ls 2>&1' the '2>&1' only applies to 'ls'. The solution would probably be something like:
There are more fancy ways to do it, but that is the clear/simple way. |
||||
|
|