You are currently viewing Linux Commands – watch

Linux Commands – watch

  • Post author:
  • Post category:Linux

Linux Commands – watch

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed touch command in Linux which is used to update the access and modification times of a file to the current time.

In this blog post, we will discuss the watch command in Linux. The watch command can be used to run a command repeatedly, displaying its output and errors (the first screenful). This allows you to watch the command output change over time. By default, the command is run every 2 seconds and display output indefinitely until interrupted.

Linux Commands – watch:

You can use watch command to run a command repeatedly displaying the output and errors.

You can use watch -d or –differences [permanent] options to highlight the differences between successive updates. watch -differences [permanent] option changes highlight to be permanent, allowing to see what has changed at least once since the first iteration.

You can use watch -n seconds or –interval seconds options to specify update interval. The command will not allow quicker than 0.1 second interval, in which the smaller values are converted. The default update interval of the watch command is 2 seconds.

You can use watch -t or –no-title options to turn off the header showing the interval, command, and current time at the top of the display, as well as the following blank line.

You can use watch -e or –errexit options to freeze updates on command error, and exit after a keypress. By default, watch command will continue to update on command error and does not exit until interrupted.

You can use watch -g or –chgexit options to exit when the output of command changes. This is very useful to track command depending upon the change in output. For example, you can track connectivity using ping command and take action depending upon the output.

You can use watch -x or –exec options to run the command on sh -c.

You can use watch -c or –color to interpret ANSI color and style sequences. By default, ANSI color and style sequences are not interpreted.

Hope you have enjoyed this article. In the next blog post, we will discuss wc command in Linux.