Warm tip: This article is reproduced from serverfault.com, please click

rsync verbose with final stats but no file list

发布于 2013-09-28 16:08:05

I see that when I use rsync with the -v option it prints the changed files list and some useful infos at the end, like the total transfer size.

Is it somewhat possible to cut out the first (long) part and just print the stats? I am using it in a script, and the log shouldn't be so long. Only the stats are useful.

Thank you.

Questioner
user2726694
Viewed
1
Ludovic Kuty 2013-09-30 20:32:39

This solution is more a "hack" than the right way to do it because the output is generated but only filtered afterwards. You can use the option --out-format.

rsync ... --out-format="" ... | grep -v -E "^sending|^created" | tr -s "\n"

The grep filter should probably be updated with unwanted lines you see in the output. The tr is here to filter the long sequence of carriage returns.

  • grep -E for extended regexes
  • grep -v to invert the match. "Selected lines are those not matching any of the specified patterns."
  • tr -s to squeeze the repeated carriage returns into a single one