‘watch’ Command For OS X

I just discovered today that the ‘watch’ command isn’t natively available on OS X. You can apparently get it through Macports. Since I don’t have Macports installed, this seemed like a very heavy solution for a rather small problem.

Looking for another solution, I opted for a basic while loop — which is a shell command. My basic command is going to look something like:

while echo "This prints every 5 seconds" ; do clear ; sleep 5 ; done

It’s not as useful as watch in that you don’t have the additional time output, but it definitely works and doesn’t require any additional installs to get the data from the command line.

For the creative and motivated, it probably wouldn’t be difficult to make a very simple wrapper script to more closely match the watch output by leveraging a while loop. You’re probably better off just getting a compiled binary at that point, but it might be an interesting exercise regardless.