tar to quickly copy thousands of small files which I pipe to
pv to show the progress and speed of the copying.
$ sudo tar c --files-from /tmp/camfilenames | pv --width 40 | sudo tar x -C /home/pi/test
...this works perfectly. Example output:
191MiB 0:00:03 [58.1MiB/s] [<=> ]
...in the terminal. But I want to do something more with this output and I have simple python script
import sys print "start" for line in sys.stdin: print "line: " + line print "end"
$ ( sudo tar c --files-from /tmp/camfilenames | pv --width 40 | sudo tar x -C /home/pi/test ) | python /home/pi/screentest.py
start 191MiB 0:00:03 [55.1MiB/s] [<=> ] end
I understand that
pv returns everything in one buffer, so how to force it to return it line by line and flush the buffer every time to output something like:
start line: 0MiB 0:00:00 ... line: 60MiB 0:00:01 ... line: 120MiB 0:00:02 ... line: 191MiB 0:00:03 ... end