watch command_examples

watch command_examples

watch – execute a program periodically, showing output fullscreen

To watch for mail, you might do

watch -n 60 from

To watch the contents of a directory change, you could use

watch -d ls -l

If you’re only interested in files owned by user joe, you might use

watch -d 'ls -l | fgrep joe'

To see the effects of quoting, try these out

watch echo $$
watch echo '$$'
watch echo "'"'$$'"'"

To see the effect of precision time keeping, try adding -p to

watch -n 10 sleep 1

You can watch for your administrator to install the latest kernel with

watch uname -r

(Note that -p isn’t guaranteed to work across reboots, especially in the face of ntpdate or other bootup time-chang‐

ing mechanisms)

Leave a Reply

Your email address will not be published. Required fields are marked *