Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn command output to a live status update?

Tags:

linux

bash

zsh

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.

like image 774
John Z. Avatar asked Jun 09 '16 15:06

John Z.


1 Answers

You can use watch

watch -n1 dropbox-cli status

Specify the time in seconds with param -n.

like image 186
cb0 Avatar answered Oct 22 '22 05:10

cb0