cd $HOME

watch - display a progress bar

As Julien pointed out, the Debian Administration website has some nice articles about “Commands you might have missed”. I came across this article ab out watch, which repeatedly run a command.

I personally use it in some backup scripts to display a progress bar. Assuming I want to copy a directory with 18 files , I can monitor the progress on the remote machine with this simple command line:

watch 't=`ls -la | wc -l`;perl -e "print \"[\",\"x\"x($t),\".\"x(18-$t),\"]\n\";"'
which outputs something like:

Every 2.0s:
[xxxxxxxxxxxxx.....]

Each x represents a file which has already been transferred. In this example, I can see quickly that 5 files still need to be transferred.

By the way, this snippet to draw bars is quite handy. Here is what I use to get visually the space remaining on a drive:

server ~% t=`df -h | grep hdr42 | awk '{print $3/$2*50}'`;perl -e "print \"[\",\"x\"x($t),\".\"x(50-$t),\"]\n\";" 
[xxxxxxxxxxxxxxxxxxxxxx................]
Back

Comments



The content of this field is kept private and will not be shown publicly.