May 2017
Beginner
552 pages
28h 47m
English
The watch command monitors the output of a command on the terminal at regular intervals. The syntax of the watch command is as follows:
$ watch COMMAND
Consider this example:
$ watch ls
Alternatively, it can be used like this:
$ watch 'df /home'
Consider the following example:
# list only directories
$ watch 'ls -l | grep "^d"'
This command will update the output at a default interval of two seconds.
The -n SECONDS option defines the time interval for updating the output:
# Monitor the output of ls -l every of 5 seconds
$ watch -n 5 'ls -l'