brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: watch -d highlights what changed between refreshes

Watch
~/tips/tip-linux-watch-diff

watch -d -n 5 'df -h /mnt/backup'

Reruns a command every few seconds and highlights the parts that changed.

You have a command whose output changes slowly, like a copy that is running or a counter that should climb. Staring at it is how you miss the one number that moved.

Wrap it in watch with the difference flag:

watch -d -n 5 'df -h /mnt/backup'

-n 5 refreshes every five seconds (the default is two). -d highlights the characters that changed since the previous run, so a growing size or a flipping state jumps out. It works nicely with ss -s, ip -s link or ls -l on a file that is being written.

The caveat: quote the command when it contains pipes or other shell characters, otherwise your own shell eats them before watch sees them. Press Ctrl+C to leave. And watch clears the screen on every refresh, so it is a viewer, not a logger. For history, write to a file instead.

I think watch is underrated. It makes any command into a live view without writing a loop, and the highlighting does the part your eyes are bad at. Add -g and it even exits when the output changes, which is useful when you are waiting for something to finish.

Further reading: watch man page, On this site: watch -n 2 runs a command every two seconds and shows the latest output, On this site: watch docker events to see exactly when a container dies

Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid

More Watch tips On the watch: Settings > SOS > Fall Detection On the watch: Settings > Noise > Noise Threshold > pick a level Open Camera Remote on the watch High Heart Rate Notifications > threshold watch -c ls --color=always -l /var/log All Watch tips (17) All topics

Link