OS X bash 'watch' command

To run a command similar to the Linux watch command on Mac OSX, do the following:

while :; do your_command; done

For example, the following will check the disk usage for the current directory via `du' every two seconds. The `echo -ne "\r"' causing the line to write over itself replacing the existing line.

while :; do echo -ne " "$(du -s .)"\r"; sleep 2s; done
View this page on GitHub.
Posted .

2 comments

Leave a Reply