Bash onliner for when you are bored


New Member
Aug 25, 2023
For some reason I do this. I start a large file transfer or backup and then I want to know how far it's got, percent complete.

So in a new terminal I write one of these:

root@pve:~# while /bin/true; do src=$(du -xms mnt | cut -f 1); dest=$(du -xms mnt2|cut -f 1); echo $(( $dest / ( $src / 100 )))% - $(( $src - $dest ))MB to g
o  ${src}MB total, ${dest}MB completed; sleep 5; done         
27% - 614279MB to go 852930MB total, 238651MB completed
28% - 613359MB to go 852930MB total, 239571MB completed
28% - 612524MB to go 852930MB total, 240406MB completed
28% - 611666MB to go 852930MB total, 241264MB completed
28% - 610784MB to go 852930MB total, 242146MB completed
28% - 609929MB to go 852930MB total, 243001MB completed

Pretty form:
while /bin/true
    src=$(du -xms mnt | cut -f 1);
    dest=$(du -xms mnt2|cut -f 1);
    echo -n $(( $dest / ( $src / 100 )))% -
    echo -n $(( $src - $dest ))MB to go 
    echo ${src}MB total, ${dest}MB completed;
    sleep 5;

It's going to take a long time. However, as a software engineer, it is not a complete waste of 20 minutes writing that one-liner to tell me that of course :)


The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!