Is there a stopwatch, so that I can measure time taken for different commands for BASH shell?
1 Answer
time [command]
returns the time taken for the command to complete.
steven@wind:~$ time du /storage -s
du: cannot read directory `/storage/lost+found': Permission denied
1548584024 /storage
real 0m4.046s
user 0m0.224s
sys 0m1.496s
steven@wind:~$ time sleep 5
real 0m5.003s
user 0m0.000s
sys 0m0.000s
steven@wind:~$
-
2Might be worth adding that (in bash,) time's output can be modified with the TIMEFORMAT variable. E.g. with the last example,
TIMEFORMAT=%R; time sleep 5
would output just the real time in seconds;5.003
. And if you want to capture time's output, mywiki.wooledge.org/BashFAQ/032 explains how.– geirhaJun 20, 2013 at 18:57