-1

Some software seems to be distributed in a new archive format:

$ file node-v18.7.0-linux-x64.tar.xz
node-v18.7.0-linux-x64.tar.xz: XZ compressed data

How do I extract this, preferably using tar (like I can with gzip or bzip2) ?

mikemaccana
  • 1,723
  • 1
  • 12
  • 16
  • 2
    “New” is relative ;-). GNU `tar` has supported `xz` archives since March 2009. – Stephen Kitt Aug 10 '22 at 14:38
  • 1
    @StephenKitt Kind of. It's a different question, so not a duplicate I think, but the solution is the same. Like 'what fruit is in a walford salad?' and 'what keeps the doctor away?' are separate question with the same answer 'apple'. Not sure what the policy is here. – mikemaccana Aug 10 '22 at 14:40
  • @mikemaccana "duplicate" questions are simply sign-posts that are worded differently but have the same solution -- exactly like this. People searching for various wording will hit the various entry-point "duplicate" questions and find themselves redirected to the single solution. It helps keep answers high-quality on SE. – Jeff Schaller Aug 10 '22 at 14:43
  • 1
    @JeffSchaller they're worded differently because they're different questions (see waldorf salad vs doctors example given previously), but I do understand. I'm glad this still exists as it'll help others who needs to extract an .xz even if they get the answer from a different question. – mikemaccana Aug 10 '22 at 16:38
  • 1
    @Bib Please be kind in comments. I had no idea that `tar` even supported non-gzip non-bzip2 formats - last I checked (which was a decade ago) it didn't, so I imagined using an external command and piping to tar. – mikemaccana Aug 10 '22 at 18:25
  • 1
    @Bib consider that the manual for tar on my Arch is more than 1k lines, man pages are really not easy to understand for those not used to them, and many users won't even know how to search through a man page as `/` isn't something you'd guess if you didn't know it. So please be a bit more patient, we're here to answer questions, after all, so we can't expect people to already know. – terdon Aug 10 '22 at 19:27

1 Answers1

4

Answering my own question to help others: tar (at least GNU tar) already handles this compression format, you can either:

  • Use '-J' to tell tar to expect XZ
tar -xJf node-v18.7.0-linux-x64.tar.xz
(file extracts)
  • Just don't specify a format and let tar detect the compression automatically:
tar -xf node-v18.7.0-linux-x64.tar.xz
(file extracts)

Or if you like to watch the progress:

tar -xvf node-v18.7.0-linux-x64.tar.xz
mikemaccana
  • 1,723
  • 1
  • 12
  • 16