I'm used to extracting tarballs with a -xfz
flag, which handles gzip and bzip2 archives.
Recently I've run into a .tar.xz
file and I would like to uncompress it in one step using tar
, how can I do that?
I'm used to extracting tarballs with a -xfz
flag, which handles gzip and bzip2 archives.
Recently I've run into a .tar.xz
file and I would like to uncompress it in one step using tar
, how can I do that?
Ubuntu includes GNU tar, which recognizes the format by itself! One command works with any supported compression method, per the manual.
etc. If tar gives a
Cannot exec
error, you may need tosudo apt install xz-utils
first.Try
tar -xJf file.pkg.tar.xz
The
-J
is the flag that specifically deals with .xz files.If for some reason the
tar
solutions don’t work (perhaps because you’re using the OS X built-ins), try this:…which is equivalent to:
Then use
tar
to untar the file.xz is a lossless data compressor. You will have to extract the tar ball from xz and then extract the tar:
Then you know to extract a tar
Source: XZ Utils - Wikipedia.
I had the same problem, the
tar xf
command was not able to extract it. To fix this, you need to install thexz-utils
package. The solution was:then:
-x
- extract files-v
- verbosely list files processed-f
- use specified archive fileJust want to add that if you have an old version of GNU tar prior to version 1.22 when the --xz and -J options became available, you could compress or decompress tar.xz files by using
--use-compress-program xz
. For example,or
If tar recognizes the compression format, you don't need a flag:
tar xvf *.tar.xz
If you need to decompress the input manually, for example because your tar is too old to recognize xz, or you need a special path:
xz -cd *.tar.xz | tar xvf -
Pipes are faster than making an uncompressed intermediate file, and use less disk space too!
Wow, that's a really good one. Was it done with 7zip on a Mac? Try this:
I like dtrx