Use a Quick and Dirty Stopwatch via the Mac Terminal

Sep 12, 2009 - 2 Comments

Terminal in macOS

Need a super easy and simple Stopwatch on the Mac, but don’t want to download anything like a third party app or utility? Look no further than the command line.

You can create an instant quick and dirty stopwatch via the Mac OS X (or linux) command line by launching the Terminal app and typing a simple command string.

How to Use a Stopwatch at Command Line of Mac OS

Try it yourself, this stopwatch trick is super easy.

To get started, launch the Terminal application, and then type the following following command string:

time cat

Now hit enter and the stopwatch begins.

At any point, you can stop the counting stopwatch by hitting Control-C on the keyboard.

Once the stopwatch has ended running, you will return to the command prompt while returning something back that looks like this:

$ time cat
^C
real 0m5.905s
user 0m0.001s
sys 0m0.003s

The top ‘real’ number is the elapsed time, that is, time that passed since executing the command.

How this stopwatch works is that you are using the ‘time’ command to measure the time of how long another command takes to execute, but since the cat command requires something to output and we are not providing anything, cat does nothing, thus creating a simple stopwatch. Great little trick, huh?

mac terminal

This uses the time command and thus works in basically every version of macOS, Mac OS X, Linux, and it should also work in just about any other version of unix that supports the time and cat commands as well.

No need for downloads or utilities, if all you need is a simple stop watch just turn to the command line. It’s perfect for situations where you have to time something in a pinch.

And yes you can also use the ‘time’ command to literally time the completion of commands as well, but that’s a topic for another article.

If you have any other tips or tricks about using the time command, or another nifty hint for creating a stopwatch or timer at the command line of Mac OS or linux, share them with us in the comments below!

.

Related articles:

Posted by: Bill Ellis in Command Line, Tips & Tricks

2 Comments

» Comments RSS Feed

  1. Vimist says:

    I was doing something quite similar to this for a while, but I wanted something a bit nicer to look at while still being in the terminal, so I wrote a tool called TermTime, you can install it pretty easily using pip (pythons package manager):

    https://github.com/vimist/termtime

  2. […] If you’re not keen on installing third party apps, you can always create a rudimentary stopwatch from the command line […]

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site