Free email newsletter: “ News


Use Bash as a stop watch

If you need to time something and don’t want to use any fancy GUI apps, you can use the following command in the Bash shell (Mac OS X or Linux terminal):
date ; read -n 1 -s ; date
Explanation: Print out time and date, wait for a single key to be pressed (-s prevents that key from being shown), and print out time and date again.

Update 2010-12-12: Great suggestion from the comments. The following is an even simpler solution (hit return at the end of the line to start the stop watch, hit return again to stop it).
time read

No comments: