Universal extractors

5,386

Solution 1

I use atool. It does the job. It works with many, though not all formats:

tar, gzip, bzip2, bzip, lzip, lzop, lzma, zip, rar, lha, arj, arc, p7zip etc.

These compression tools are still needed, though as atool is simply a front end for them.

I particularly like the als command it provides which lists the contents of any supported archive format.

The main atool command uses its own flags for extracting archives (passing the appropriate flags to the specific underlying extraction tools).

Oh, and it's in some distributions' repositories (Fedora in my case, though as I recall, back when I used Ubuntu it wasn't in their repos then. and I installed from a tarball.).

Update on Repositories: atool is in the following distributions' repositories (current releases checked only):

  • Fedora
  • Debian (thanks @terdon, and, presumably, it's derivatives like Ubuntu)
  • Ubuntu (q.e.d., and, presumably, derivatives like Mint)
  • Open Suse
  • CentOS (and, presumably, RHEL)
  • Arch Linux

I'm sure there are others... plausibly, most modern distributions.

Answer for Updated Question "How can I configure something like atool to not use unzip to extract zip files ... and to use gunzip instead":

Edit the atool config file ~/.atoolrc and add the line:

path_unzip /usr/bin/gunzip

with the correct path to your gunzip program.

See the man page for the complete list of possible variables you can put in this config file, of which there are a lot. If the command line options necessary for gunzip are different than unzip, you may have to modify the atool source (perl) itself.

Solution 2

The AVFS filesystem presents a view of the filesystem where every archive file (e.g. /path/to/foo.zip) is accessible as a directory (~/.avfs/path/to/foo/zip# for this example). AVFS provides read-only access to most common archive file formats.

mountavfs
cp -Rp ~/.avfs$PWD/large_file.zip\# extraction_directory

Avfs uses external helpers which can be easily configured by editing files in /usr (unfortunately there's no way as of avfs 1.0 to use files in /usr/local or in your home directory, you need to edit files in /usr or recompile). /usr/share/avfs/extfs/ext-uzip is the script to deal with .zip files, change it if you don't want to use /usr/bin/unzip. You may be able to get away with using 7z instead: try editing /usr/share/avfs/extfs/extfs.ini and change the line ext-uzip to u7z .zip.

Share:
5,386

Related videos on Youtube

Amelio Vazquez-Reina
Author by

Amelio Vazquez-Reina

I'm passionate about people, technology and research. Some of my favorite quotes: "Far better an approximate answer to the right question than an exact answer to the wrong question" -- J. Tukey, 1962. "Your title makes you a manager, your people make you a leader" -- Donna Dubinsky, quoted in "Trillion Dollar Coach", 2019.

Updated on September 18, 2022

Comments

  • Amelio Vazquez-Reina
    Amelio Vazquez-Reina over 1 year

    With an increasing number of archive/compression file formats, is there a single free/open-source command line tool to rule them all? Perhaps something with a consistent / unified set of flags? (note my friendly implicit reference to tar)

    I once run into a set of aliases meant to largely simplify the task of compressing/de-compressing files with bindings to tar and other utils, but I can't find this anymore.

    Update: How can I configure something like atool to not use unzip to extract zip files (which apparently can't handle files larger than 4GB) and to use gunzip instead?

    $ aunpack large_file.zip
    error:  Zip file too big (greater than 4294959102 bytes)
    Archive:  large_file.zip
    warning [large_file.zip]:  1491344848 extra bytes at beginning or within zipfile
      (attempting to process anyway)
    error [large_file.zip]:  start of central directory not found;
      zipfile corrupt.
      (please check that you have transferred or created the zipfile in the
      appropriate BINARY mode and that you have compiled UnZip properly)
    aunpack: unzip ...: non-zero return-code
    
    • Admin
      Admin about 11 years
      yet another solution: packages.qa.debian.org/u/unp.html
    • Admin
      Admin about 11 years
      @frostschutz. Do you know if there is anything that may make unpack different from atool?
    • Admin
      Admin about 11 years
      Dunno. As Evan's answer shows, such a program is fairly trivial. Use whatever works for you. For unpacking zip files, my personal preference is 7z.
    • Admin
      Admin about 11 years
      @user815423426 I've added instructions for your updated question to my existing answer.
    • Admin
      Admin over 3 years
  • Admin
    Admin about 11 years
    This looks great. Is this for bash?
  • Admin
    Admin about 11 years
    I've only tested this with bash and zsh, but it should work with sh as well.
  • Amelio Vazquez-Reina
    Amelio Vazquez-Reina about 11 years
    Thanks. This looks great. Do you know if, aside from being able to download the tarball, there is a (git/bzr) repository for it, or perhaps for a fork of it?
  • Sleeping_Giant
    Sleeping_Giant about 11 years
    There doesn't appear to be a git repo for it. There is a, shudder, cvs repo: savannah.nongnu.org/cvs/?group=atool . However, the source is in the tarball and the tool is written in perl, so easily modifiable by you or anyone who feels the urge.
  • terdon
    terdon about 11 years
    @user815423426 it is also in the Debian repos.
  • Admin
    Admin about 11 years
    This is exceptionally aesthetically pleasing for a shell function. One caveat would be that you'd want to make sure you've got all the relevant binaries installed, or remove lines for those you don't have installed.