Universal extractors

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.


Here's a little shell function that takes care of several archive types.

extract () {
    if [ ! -f "$1" ] ; then
        echo "'$1' does not exist."
        return 1
    fi

    case "$1" in
        *.tar.bz2)   tar xvjf "$1"   ;;
        *.tar.xz)    tar xvJf "$1"   ;;
        *.tar.gz)    tar xvzf "$1"   ;;
        *.bz2)       bunzip2 "$1"    ;;
        *.rar)       rar x "$1"      ;;
        *.gz)        gunzip "$1"     ;;
        *.tar)       tar xvf "$1"    ;;
        *.tbz2)      tar xvjf "$1"   ;;
        *.tgz)       tar xvzf "$1"   ;;
        *.zip)       unzip "$1"      ;;
        *.Z)         uncompress "$1" ;;
        *.xz)        xz -d "$1"      ;;
        *.7z)        7z x "$1"       ;;
        *.a)         ar x "$1"       ;;
        *)           echo "Unable to extract '$1'." ;;
    esac
}

I found the original version of this function somewhere online and modified it a bit to extract ar archives and xz compressed tar archives.


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.