Skip to content

Instantly share code, notes, and snippets.

@ng-pe
Last active June 25, 2019 06:02
Show Gist options
  • Save ng-pe/b59eca23c603e70145e4 to your computer and use it in GitHub Desktop.
Save ng-pe/b59eca23c603e70145e4 to your computer and use it in GitHub Desktop.
Tar with percent progress
#!/bin/bash
# TAR with progress demo
# in this Gist "demo.data" is file to archive
total=`du demo.data -B10K --apparent-size | cut -f1`
export total=$total
BZIP2="-2 -s" tar --checkpoint=1 --checkpoint-action=exec=' printf "%03d/100\r" $((100*$TAR_CHECKPOINT/$total)) ' -cjvf demo.tar.bz2 demo.data
# output demo :
#./demoscript.sh
#demo.data
#009/100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment