6

I would like to know if there is a tool that would enable you to watch how the program output changes live. Something like tail -f but instead of monitoring the file changes, it would repeatedly call some executable and display it live.

For example, if the tool is caled foobar and I would call foobar 'ps -Al', it would behave kind of like top - displaying the output in real time.

  • Do you want to watch a file for changes and run a command, or watch the commands output for changes and run it at a set interval? – Evan Carroll Dec 30 '18 at 22:55
14

Try watch. From the manpage:

Name

watch - execute a program periodically, showing output fullscreen

Synopsis

watch [-dhvt] [-n <seconds>] [--differences[=cumulative]] [--help] [--interval=<seconds>] [--no-title] [--version] <command>

Description

watch runs command repeatedly, displaying its output (the first screenfull). This allows you to watch the program output change over time. By default, the program is run every 2 seconds; use -n or --interval to specify a different interval.

The -d or --differences flag will highlight the differences between successive updates. The --cumulative option makes highlighting "sticky", presenting a running display of all positions that have ever changed. [...]

watch will run until interrupted.

Note that "realtime" would have to be approximated by "once a second" (for example) here...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy