Harry R. Schwartz

Code writer, sometime Internet enthusiast, attractive nuisance.

The author at the Palais du Luxembourg in Paris, November 2022. hacker news gitlab sourcehut pinboard librarything 1B41 8F2C 23DE DD9C 807E A74F 841B 3DAE 25AE 721B

Vancouver

British Columbia

Canada

vegan


Compression Algorithm Detection with tar

hrs

Published .
Tags: beards.

EDIT: Aubrey Raech tells me that even the -a isn’t necessary! Automatic detection occurs by default, so you can unpack any compressed tarball with just:

$ tar xf foo.tar.gz

Good grief. So many years, so many wasted keystrokes. Thanks, Aubrey!


I’ve always unpacked tarballs manually according to extension:

  • tar xzvf foo.tar.gz
  • tar xjvf foo.tar.bz2
  • tar xJvf foo.tar.xz
  • tar xZvf foo.tar.Z

I just happened to check the manpage for the first time in a decade or so and stumbled across this gem:

-a, --auto-compress
       Use archive suffix to determine the compression program.

Nice! Instead of remembering the arbitrary flag for each compression algorithm, you can always use tar xavf and tar will figure out the right thing to do.

There’s some good stuff in that documentation, it turns out.


You might like these textually similar articles: