Skip to content

Instantly share code, notes, and snippets.

@glinton
Last active April 2, 2018 21:29
Show Gist options
  • Save glinton/03c495170291b3a0bba545ffb7aaf04b to your computer and use it in GitHub Desktop.
Save glinton/03c495170291b3a0bba545ffb7aaf04b to your computer and use it in GitHub Desktop.
Rosetta permute. Generate simple progress from rsync.

Rosetta rsync output parsing

Comparing various text "permuters" to show pretty output for rsync

awk Winner

rsync --info=progress2 * test@192.168.1.142:/tmp/new/ 2> /dev/null | stdbuf -i0 -o0 tr $'\r' $'\n' | awk '{printf "\rSyncing image: %s - %s",$2,$3}'
# Syncing image: 100% - 37.30MB/s
# real	0m3.012s

perl Runner up

rsync --info=progress2 * test@192.168.1.142:/tmp/new/ 2> /dev/null | perl -e '$/ = "\r"; $| = 1; while(<STDIN>){/.* (\d+%)   (.*\/s).*/;print "\rSyncing image: $1 - $2";}'
# Syncing image: 100% - 30.56MB/s
# real	0m3.607s

sed Dead last

rsync --info=progress2 * test@192.168.1.142:/tmp/new/ 2> /dev/null | stdbuf -i0 -o0 tr $'\r' $'\n' | sed -une  "s|.* \([0-9]*\%\).* \([0-9]*\.[0-9]*[a-zA-Z/]*\) .*|Syncing image: \1 - \2|p" | stdbuf -i0 -o0 tr $'\n' $'\r'
# Syncing image: 100% - 27.18MB/s
# real	0m4.000s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment