Для того, чтобы скачивать и разархивировать (untar) [tar], [tar.gz] или [tar.bz2] файлы «на лету», не сохраняя самих архивов, используйте одну из следующих команд.
- Никаких временных файлов;
- Никакого лишнего вывода;
- Минимальное использование оперативной памяти и дискового пространства.
Приведенные способы скачивания и разархивирования «на лету», являются самыми быстрыми и компактными.
Скачать и Распаковать Архив с помощью 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
Скачать и Распаковать Архив с помощью 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
Опции | Описание |
---|---|
-x | извлечь файлы из архива |
-z | разархивировать содержимое, сжатое с помощью программы gzip [tar.gz] |
-j | разархивировать содержимое, сжатое с помощью программы bzip2 [tar.bz2] |
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
One important point: These hints are all for GNU tar. If you’re on MacOS or some BSD, you may get a nasty surprise to see that they don’t support the same arguments. With some formats (gzip, bzip2), the local `tar` program might support it, but in other cases (xz) it might not.
The .tar.xz extension that can be decompressed with `tar -xJ`.