Skip to content

Instantly share code, notes, and snippets.

@landsman
Created April 18, 2021 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landsman/d112364af04f052d382a27fda285407d to your computer and use it in GitHub Desktop.
Save landsman/d112364af04f052d382a27fda285407d to your computer and use it in GitHub Desktop.
compress file with progress bar
function compress () {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: compress <path/folder-or-file> <new-file.tar.gz>"
return 1
fi
tar cf - $1 -P | pv -s $(du -sb $1 | awk '{print $1}') | gzip > $2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment