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]

One Reply to “HowTo: Download and Extract (untar) TAR Archive with One Command”

  1. I faced with the following issue:
    ]# wget -O – https://pocoproject.org/releases/poco-1.9.0/poco-1.9.0.tar.bz2 –no-check-certificate | tar -xj
    tar (grandchild): bzip2: Cannot exec: No such file or directory
    tar (grandchild): Error is not recoverable: exiting now
    https://pocoproject.org/releases/poco-1.9.0/poco-1.9.0.tar.bz2
    Length: 2635609 (2.5M) [application/x-bzip2]
    Saving to: ‘STDOUT’

    0% [ ] 0 –.-K/s tar: Child died with signal 13
    tar: Error is not recoverable: exiting now
    0% [ ] 16,384 102KB/s in 0.2s

    Cannot write to ‘-’ (Success).

    OS is RHEL 7.3

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.