title: Clear Screen in "watch" Command
body: <p>I commonly run a lot of programs from the same shell before using the watch command to monitor the programs for completion. (I filter the ps command a bit, but this example is simpler.)</p>
  
  <pre><code>sleep 10 &amp;&amp; for i in {1..100}; do echo $i; done &amp;
  watch -n 5 ps aux
  </code></pre>
  
  <p>The watch command clears the terminal so that the output of the command is clear and there is no clutter.</p>
  
  <p><a href="https://i.stack.imgur.com/B7QbC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B7QbC.jpg" alt="Output of watch command"></a></p>
  
  <p>When another program outputs such as the echo statements in the example, the result is a little weird. It prints strangely and the results seem to depend on the size of the output. Even though watch should have rerun the "ps aux" command, it does not overwrite the output of the "echo" commands.</p>
  
  <p><a href="https://i.stack.imgur.com/6rTUY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6rTUY.jpg" alt="After sleep timer has finished"></a></p>
  
  <p>Is there something like this that would prevent the output of other programs from covering watch output?</p>
  
  <pre><code>watch -n 5 ClearScreenSomehow &amp;&amp; ps aux
  </code></pre>