Skip to content

Instantly share code, notes, and snippets.

@hradec
Forked from Kautenja/tar-progress.md
Created September 2, 2023 03:05
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 hradec/d301959200ba608d2e8334f0e9ab1cfc to your computer and use it in GitHub Desktop.
Save hradec/d301959200ba608d2e8334f0e9ab1cfc to your computer and use it in GitHub Desktop.
one-liners for using tar with gzip and pv for a progress bar

Compress

tar cf - <files> -P | pv -s $(du -sb <files> | awk '{print $1}') | gzip > <some .tar.gz file>

where:

  • <files> is the root-mounted (i.e. starts with /) path to the files
  • <some .tar.gz file> is the output tarball to create

Decompress

pv <some .tar.gz file> | tar -xvzf - -C <some directory>

where:

  • <some .tar.gz file> is the path to the tarball to extract
  • <some directory> is the directory to extract the tarball to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment