5W site logo 5W - мой домашний сайт-блог с картинками, кино и плюшками.


Download and Extract (untar) TAR Archive with One Command
Tips and Tricks

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]
You can do it by telling wget to output its payload to stdout:

wget -qO- your_link_here | tar xvz

To specify a target directory:

wget -qO- your_link_here | tar xvz -C /target/directory


If you happen to have GNU tar

wget -qO- your_link_here | tar --transform 's/^dbt2-' -xvz
tar xvzf -C /tmp/ < <(wget -q -O - http://foo.com/myfile.tar.gz)
wget http://wordpress.org/latest.tar.gz && tar xvzf latest.tar.gz && rm latest.tar.gz