1

I'm trying to change the output position of a file transfer made with rsync, as shown below:

rsync -zvh --progress ubuntu-19.10-desktop-amd64.iso /home/lnxusr/Downloads/ 

From this:

ubuntu-19.10-desktop-amd64.iso
        144.67M   5%   34.50MB/s    0:01:05

To this:

ubuntu-19.10-desktop-amd64.iso
144.67M   5%   34.50MB/s    0:01:05

However, when I pipe it to | sed -u 's/[^\s]+//', I only get the static output which is:

ubuntu-19.10-desktop-amd64.iso

I tried the answer suggested here to turn off the buffering process with stdbuf -o0 but got the same result as before.

Anyone knows this kind of output manipulation? or if is it even possible to position this output?

thiggy01
  • 431
  • Why do you need leading spaces removed? Perhaps there is another solution to your problem. – WinEunuuchs2Unix Dec 07 '19 at 21:49
  • AFAIK [^\s] is going to match anything that is not literal \ or s and + is also literal unless you switch to extended regex mode (-E or -r). Try sed -E 's/^\s+//' – steeldriver Dec 07 '19 at 22:10
  • @WinEunuuchs2Unix I'm trying to get a more precise positioning and design in a script output. @steeldriver [^\s] matches all leading spaces. I tested it with a simple file. No need for extended regex. I think that's more of a buffer problem, but have no idea if it has a turn around. – thiggy01 Dec 07 '19 at 23:48

1 Answers1

0

Another answer might provide a better way:

rsync has a --info option that can be used to not only output the current progress, but also the transfer rate and elapsed time:

--info=FLAGS            fine-grained informational verbosity

The explanation of how to use it comes under the -P option in the man page:

-P     The -P option is equivalent to --partial --progress.  Its purpose is to
       make it much easier to specify these two options for a long transfer that
       may be interrupted.

       There is also a --info=progress2 option that outputs statistics based on
       the whole transfer, rather than individual files.  Use this flag
       without  out‐putting  a  filename  (e.g. avoid -v or specify --info=name0)
       if you want to see how the transfer is doing without scrolling the screen 
       with  a  lot  of names.   (You  don’t  need  to specify the --progress
       option in order to use --info=progress2.)

So trying using:

rsync -zvh --info=progress2 --info=name0 ubuntu-19.10-desktop-amd64.iso /home/lnxusr/Downloads/

Notes:

  • This gives the progress of the entire transfer, not for individual filenames.
  • I do not have your source file nor target directory to test on my system.
  • Thanks for your answer, but that doesn't remove the leading spaces of the rsync progress output. Maybe there's no solution to this kind of manipulation. – thiggy01 Dec 08 '19 at 18:55