Back to the command reference

watch

ShellFundamentals In real Linux

Run a command repeatedly and show its output

Name: watch

This command needs a real Linux system; you can practise it in real Linux mode.

Description

watch reruns a command every interval (2 seconds by default) and shows the latest output full-screen, ideal for watching changing state such as disk space, processes or a directory. -d highlights what changed.

Syntax

watch [OPTION]... COMMAND

Common options

-n / --interval SECONDSInterval in seconds (default 2)
-d / --differencesHighlight differences
-t / --no-titleLeave out the title line
-g / --chgexitQuit as soon as the output changes
-c / --colorShow colours

Examples

  • $ watch -n 1 df -h

    Refresh disk usage every second

    Explain
  • $ watch -d 'ls -l'

    Watch a directory change

    Explain

Related