View program output with watch

by
Ryan
on
October 6, 2008

Watch runs a program at regular interval and continuously displays the output. This allows you keep track of the changes that are occurring in the program over time.

Run watch in the following way.

watch [options] command

By default watch updates the command output every 2 seconds. To change this interval us the ‘-n seconds‘ option.

This will keep an eye on the changes occurring in your home directory. This will update the command output every second.

$ watch -n 1 ls -l ~/

If you use the ‘-d‘ option, watch will highlight the differences between the current and previous update. Adding ‘-d=cumulative‘ will make the highlights permanent, allowing you to see what has changed throughout the entire run.

$ watch -d=cumulative ls -l ~/

String longer commands together by enclosing them in single quotes.

$ watch 'cat logfile | grep somestring'

Watch will continue to run until you exit the program by pressing Ctrl-C.

No Comments
commands
,

No related posts.

Comments (0)

No comments yet

Trackbacks (0)

No trackbacks yet

Leave a Comment

(displayed with your post)
(will not be published)
(optional)
Copyright 2008-2010 WiredRevolution.com. All rights reserved.