theshell.ch/site/pages/cmd/interm/watch.html
maggicl 440af92f7b interm: Added pages on watch and curl
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@183 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-14 17:56:45 +00:00

41 lines
1.2 KiB
HTML

---
layout: page
category-page: intermediate
category-title: Intermediate commands
tags: watch repeat track analyse seconds
author: Claudio Maggioni
title: watch
---
<p>
The <code>watch</code> command is a system utility able to execute a command
every <em>n</em> seconds by clearing the screen and displaying the
output of the command each time the interval is over. This command is very
simple to use and very effective: it can be used to check the size in bytes
of a file while downloading it, or it can be used on <em>Linux</em> to jiggle
around the mouse every ~5 minutes with the command <code>xdotool</code> in
order to keep the computer awake.
</p>
<h3>Usage</h3>
<p>
<code>watch</code> has a very simple syntax: the amount in seconds to wait
between executions is specified in seconds using the <code>-n</code> flag
and the default value is <em>2</em>. Also, differences between older and
newer outputs are highlighted if the <code>-d</code> flag is used.
</p>
<h4>Watch the size of "ubuntu.iso" every 5 seconds</h4>
<pre>
watch -n 5 du -h ubuntu.iso
</pre>
<h4>Watch the contents of "site.html" every 2 seconds and highlight the
differencies between iterations</h4>
<pre>
watch -d cat site.html
</pre>