BASH has its built-in variant of time
. If you do a man time
you will find that a lot of those option listed there won't work with time
command. The man page warns BASH users that they may use explicit path to time
.
The explicit path is /usr/bin/time
on Ubuntu, but you can find it out with $ which time
.
With the proper path, you can use the -f
or --format
option and a lot of formatting parameters that will nicely format your result which you can store to a variable as well.
STUFF_HERE=`/usr/bin/time -f %E sleep 1
2>&1`