Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-20-2012, 02:52 PM   #1
LQ Newbie
Registered: Jul 2012
Posts: 10

Rep: Reputation: Disabled
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?
Old 08-20-2012, 08:53 PM   #2
Registered: Aug 2012
Location: /home/byannoni
Distribution: Arch
Posts: 128

Rep: Reputation: 36
Try this:
rsync -a --progress test.tar.gz /media/sdb1 | awk '{printf "\r%s", $2}'
1 members found this post helpful.
Old 08-21-2012, 09:39 AM   #3
LQ Newbie
Registered: Jul 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
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
Old 08-21-2012, 04:12 PM   #4
LQ Newbie
Registered: Jul 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
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 '%'


awk, rsync, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mv with progress bar gbowden Linux - General 28 08-14-2013 04:42 AM
cp progress bar edwardsiow Linux - General 26 09-04-2011 08:53 AM
can't capture scp progress bar in output redirect hedpe Programming 7 10-31-2010 11:26 PM
how to design progress meter with dialog mox Joydeep Bakshi Programming 9 09-26-2007 02:41 AM
cp: progress bar chii-chan Linux - General 2 10-30-2003 06:30 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration