Skip to content

Instantly share code, notes, and snippets.

@ng-pe
ng-pe / tarWithProgress.sh
Last active June 25, 2019 06:02
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