HowTo: Download and Extract (untar) TAR Archive with One Command

Use one of the following commands to download and extract (untar) [tar], [tar.gz] or [tar.bz2] files “on fly”, without saving archive themselves.

  • No temporary files;
  • No Extra output;
  • Minimal file space and memory usage.

The following methods are most fast and compact for downloading and unpacking archives.

Download and Extract Archives with WGET

$ wget http://example.com/archive.tar -O - | tar -x
$ wget http://example.com/archive.tar.gz -O - | tar -xz
$ wget http://example.com/archive.tar.bz2 -O - | tar -xj

Download and Extract Archives with CURL

$ curl http://example.com/archive.tar | tar -x
$ curl http://example.com/archive.tar.gz | tar -xz
$ curl http://example.com/archive.tar.bz2 | tar -xj
Option Description
-x extract files from an archive
-z decompress the contents of the compressed archive created by gzip program [tar.gz]
-j decompress the contents of the compressed archive created by bzip2 program [tar.bz2]