watch Cheat Sheet
The watch command executes a program periodically, and displays the output.
Command
$ watch ls
Show the output of the ls command,
refreshing every 2 seconds
$ watch ls -1 | wc -l
Show the number of files in a directory,
refreshing every 2 seconds
$ watch -n 10 df -h /data
Show free disk space on /data, refreshing
every 10 seconds
$ watch --differences ls -l
big-file-download
Show file size of big-file-download (this
shows progress as well as file size)
$ watch --differences=permanent
ls -l
Show details of all files, highlighting
cumulative changes since the initial run.
Options
-n, --interval 10
Set the number of seconds between each refresh to 10
-d, --differences
Highlight differences since the previous refresh
-d permanent
Highlight differences since initial run
-x, --exec
Pass command to exec instead of sh -c to avoid any need for
additional quoting in complex commands
-t, --no-title
Do not show the output heading
-c, --color
Interpret ANSI color and style sequences
Moshe Zadke CC BY-SA 4.0 Opensource.com