-   Programming (
-   -   Parsing rync output for progress bar in dialog (

yamanoorsai 08-20-2012 02:52 PM

Parsing rync output for progress bar in dialog
I am trying to display a progress bar in dialog using the output of rsync command. I found this answer while doing my search. The answer is useful only if you are transferring a large number of uncompressed files. I am trying to transfer a single large compressed file. I tried the following:


rsync -a --progress test.tar.gz /media/sdb1 > test.txt
My output looks like this:


32768  0%    0.00kB/s    0:00:00 
80510976  2%  76.75MB/s    0:00:48

I need the percentage data from the second column. Is there a way to print only 1 line of data at a time? Is there a better way of parsing the output of rsync command to obtain the percentage of progress?

byannoni 08-20-2012 08:53 PM

Try this:

rsync -a --progress test.tar.gz /media/sdb1 | awk '{printf "\r%s", $2}'

yamanoorsai 08-21-2012 09:39 AM

I tried your suggestion. The values being printed are:





This is being printed after the script has executed. I need to turn off the buffer. I am still not able to print the percentage data

yamanoorsai 08-21-2012 04:12 PM

I figured it out. I did it as follows:


rsync -a --progress data-000.tar.gz /media/PENDRIVE | unbuffer -p grep -o "[0-9]*%" | tr -d '%'

All times are GMT -5. The time now is 11:10 AM.