Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a stopwatch, so that I can measure time taken for different commands for BASH shell?

share|improve this question
add comment

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:~$
share|improve this answer
1  
Might 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. –  geirha Jun 20 '13 at 18:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.