Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
1  
yet another solution: packages.qa.debian.org/u/unp.html –  frostschutz Apr 23 '13 at 0:25
    
@frostschutz. Do you know if there is anything that may make unpack different from atool? –  user815423426 Apr 23 '13 at 19:13
    
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. –  frostschutz Apr 23 '13 at 20:23
1  
@user815423426 I've added instructions for your updated question to my existing answer. –  SuperMagic Apr 23 '13 at 20:48

3 Answers 3

up vote 9 down vote accepted

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.

share|improve this answer
    
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? –  user815423426 Apr 22 '13 at 22:59
    
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. –  SuperMagic Apr 22 '13 at 23:40
1  
@user815423426 it is also in the Debian repos. –  terdon Apr 23 '13 at 0:47

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" ;;
        *.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.

share|improve this answer
    
This looks great. Is this for bash? –  user815423426 Apr 22 '13 at 21:14
    
I've only tested this with bash and zsh, but it should work with sh as well. –  paraxor Apr 22 '13 at 21:15
    
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. –  bgvaughan Apr 26 '13 at 17:19

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|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.