John Z. John Z. - 1 year ago 75
Linux Question

How to turn command output to a live status update?

I am curious if there's a tool or an easy way to continually execute a certain command in given intervals, and reprint its output into same place on the screen.

The example that prompted me to think about it is 'dropbox-cli status'. Manually executed:

$> dropbox-cli status
Syncing (6,762 files remaining)
Indexing 3,481 files...
$> dropbox-cli status
Syncing (5,162 files remaining)
Indexing 2,681 files...

I am looking for:

$> tracker --interval=1s "dropbox-cli status"
Syncing (6,743 files remaining)
Indexing 3,483 files

The imaginary command 'tracker' would block and the two output lines would be continually reprinted over every second, rather than creating an appending log output.

cb0 cb0
Answer Source

You can use watch

watch -n1 dropbox-cli status

Specify the time in seconds with param -n.