e – Extract Any Archive

Share

What?

With this little tool you can extract almost any archive in Linux so you do not need to remember which tool and what command lines are necessary.

Why?

I got fed up with the sheer impossible number of compression formats out there. I am an avid linux command line user, but remembering 20 different commands with strange switches to get to the juicy content of a compressed files is too much for me.

Therefore I have just happily spent a few hours of my life to write the application e that identifies which extraction tool to call with what parameter in order to save me precious seconds of rereading forgotten manpages.

Usage

This marvelous extraction tool works like this:

  • Extract a zip file:
    e file.zip
  • Extract a rar file:
    e file.rar
  • Extract several archives, one after another:
    e a.tar.gz b.tar.bz2 c.cab d.deb e.rpm
  • Extract every file from the current directory:
    e *

If possible, e identifies the file format by the content and not by the extension, so for most filetypes e can extract it no matter how you name it. It supports rar, zip, tar.gz, tar.bz2, cab, ace, 7zip, dep, rpm, lha, lzop, rzip, and some more; it is very easy to extend it to support other compression utilities.

I was also inspired by the ugliness of the tool unp which tries to do exactly what e does. I did not like the implementation (written in Perl), and thought I can have the same features in a much simpler and more extensible way. The result is that e is just about 80 lines of code, where most of it is either comment or rules that define when to call what. If you know Ruby, have a look at the code.

Installation

For the impatient, installation on Ubuntu:

sudo apt-get install ruby
wget http://martin.ankerl.com/files/e
chmod a+x e
sudo mv e /usr/local/bin

Step by step:

  1. e is written in Ruby, so you need to install this.
  2. Download e from here
  3. copy e into your /usr/local/bin directory
  4. make it executable with chmod +x /usr/local/bin/e.

If you find an archive that e cannot extract and you know a working rule for it, please tell me and I will integrate it.

Download

Requirements

Apart from Ruby, e uses the linux tool file to determine what kind of archive it is dealing with. This tool should be available on any proper Linux installation. Once e knows the archive type, the appropriate extraction tool is executed. You might need to install a missing tools if you do not have it already.

ChangeLog

Here you can find the changes e has undergone over time.

25th June 2009
Command for NanoZip added.
Extracting RPM now preserves the original file timestamps (thanks to Michael Gruys)
14th January 2009
Support for PowerISO added.
When RAR extraction fails, broken files are not deleted any more.
24th February 2008
Support for FreeArc added, when the extension .arc is used.
8th January 2008
Added support for extraction of self-extracting zip, thanks for Samuel Jones for recognizing this. When e is called without parameters, it shows the release date and a copyright.
25th February 2007
When extracting multiple archives and extraction fails, e now continues to extract the other files and prints an error message about all the files when it has finished.
28th December 2006
In Ubuntu the 7z executable is now called 7zr. Now e works with the executables 7z, 7za, and 7zr.
10th December 2006
Added rules for ar, cpio, dar, uharc, and zzip. For uharc you need wine, and uharc.exe in your path.
14th August 2006
Added comments, fixed a typo
12th August 2006
ADD Extraction of debian packages with ar if dpkg is not available
ADD support for LZMA tar archives (extension has to be .tar.lzma or .tlz)
11th August 2006
First public release of e.
Share
  • damentz

    wow thx this is really useful, i dont know how many times ive resorted to taking the longer and buggier gui approach because i dont want to learn how to extract certain files through the terminal

  • shevegen

    There is a way to extract .deb packages if you dont have dpkg installed (i.e. on non debian systems)

    ar -x name_of_deb_package.deb

    By the way, are there any other formats missing?

  • http://martin.ankerl.com/ martinus

    thanks shevegen, the new version of e now uses ar if dpkg fails or is not available.

    I am sure there are formats missing, but I do not think I have ever used any other format then the ones supported.

    Update: I have just added LZMA support :-)

  • Pingback: redemption in a blog

  • Will

    You might want to change extrationSuccess to extractionSuccess.

  • http://martin.ankerl.com/ martinus

    thanx Will, I fixed that.

  • Aaron

    Looks nice, but it seems to be missing one feature from the script I currently use for this purpose:

    http://www.nongnu.org/atool/

    atool deals better (IMO) with archives that don’t have a containing directory. It does this by unpacking into a temporary directory. If once the extraction is complete it has only one child, that’s moved to the same directory as the archive. Otherwise, the temporary directory is given a name based on the archive file’s name.

    Besides extracting archives, it also includes programs to list archive contents, create new archives, compare 2 archive files (using diff).

    One drawback to atool as opposed to this script, is that atool uses archive file name to determine the type of archive rather than using the file command. Although this is what allows it to do archive creation.

  • csabahenk

    Do you know of libarchive?

    http://people.freebsd.org/~kientzle/libarchive/

    It comes with the bsdtar utility which is an universal archiver. Its great advantage is that is has no external dependencies.

    e would make sense anyway as a ruby llibrary. It sounds to be useful to be able to access any archived content via an unified API. Possibly it’s already there, alltohugh the examples doesn’t reveal this use case.

  • http://jozilla.be/ Anonymous

    I tried it on my Powerbook. I haven’t tested it vigorously, but it seems to work at a quick glimpse.

    So you could add “Mac OS X” in addition to Linux as the supported platforms :-)

  • Pingback: Programming Kung Fu » Program “e” updated

  • Pingback: “e” — New Release of Extract Any Archive — Martin Ankerl

  • Mike

    Just dropping a big thanks for this extremely handy utility. Nothing else to say that hasn’t already been said above.

  • Pingback: La otra bola de cristal » Blog Archive » Otra manera de descomprimir rápida y fácilmente

  • Pingback: Linux Music » Blog Archive » Descomprime Archivos De Forma Chupá En Linux Con E

  • Pingback: links for 2007-11-13 « Where Is All This Leading To?

  • christy donnelly

    hello martin.christy here.i got my first computer 6 months ago and almost immediately stumbled across linux.did not like windows!i have just begun to dabble in the terminal.what a headwreck!now,ive come across E.i have managed to get ruby into usr/bin but dont know how to get the script of E into it.any help would be really appreciated as E would take decades off my zip zap rar tar unrar nightmare. yours….christy.

  • http://martin.ankerl.com Martin Ankerl

    If you use ubuntu, you can try the installation routine that I have described above. If that does not work, you have to be a little bit more precise or I have no idea what your problem is!

  • C D

    hello martin.thanks for your reply.im using elive ,debian.i just dont understand how to put E into usr/bin.sorry for bothering you.

  • http://martin.ankerl.com Martin Ankerl

    move it to /usr/local/bin:

    sudo mv e /usr/local/bin
  • C D

    martin. you and E are a blessing.i may have a chance of staying with linux after all.thank you!

  • Jordan_U
  • http://imnotpete.com Sam Jones

    wonderful script. saved me a lot of trouble since I found it. Only problem I’ve seen is that it doesn’t always work for Windows-generated zip files.

    sjones[unzip]$ e kit.zip

    ERROR extraction not successful with these files:
    kit.zip: MS-DOS executable PE for MS Windows (GUI) Intel 80386 32-bit, ZIP self-extracting archive (WinZip)
    sjones[unzip]$

    As far as I can tell, this file is just not recognized by contents, so I added this to the script:

    rules.push [ :name, /(\.zip)$/, "unzip %FILE%" ]

    Thanks again for the great tool :-)

  • http://martin.ankerl.com Martin Ankerl

    Hi Sam, thanks for that! I have updated e and the changelog on this page.

  • Matt Chamberlain

    Thanks so much! Great tool!

  • http://www.bussa.com Carra

    Using Fedora 8 — works, but cosmetic bug: I’m extracting a .deb file and don’t have dpkg. e generates an error on dpkg then run ar and quietly finishes. From a new user look, it looks like things didn’t work when they actually did.

    Error was: sh: dpkg: command not found

    If there were some way to generate that error ONLY IF things didn’t work *at all*, that’d be nice. (No news is good news, right?) Maybe redirect all stdout/stderr to temp files, then print it if all system() calls fail? (Assuming that THEY all produce reasonable return codes, that is.)

    Also you might think of putting a version stamp in your script, or at least get ‘e –version’ to work.

    Nice script, even if it ISN’T perl. ;-)

  • http://martin.ankerl.com/ Martin Ankerl

    hi carra, I have updated e with a litte version information when you dont specify any parameters. It also supports FreeArc now.
    As for any extensions, I consider e as feature complete, any modifications that go beyond adding other rules would have to be done by somebody else. So feel free to rewrite it in perl :-)

    Oh, and here is also another version of e that has more features: http://thoughtfolder.com/2008-02-01-the-script-i-use-every-day.html

  • Pingback: e??????????????? | LinuxDig

  • info_tech_guy

    /tmp$ /usr/local/bin/e hm_setup.exe

    ERROR extraction not successful with these files:
    hm_setup.exe: MS-DOS executable PE for MS Windows (GUI) Intel 80386 32-bit

  • http://martin.ankerl.com/ Martin Ankerl

    Hi, well it can’t do wonders. Some .exe are zip file with small self-extraction wrappers, and e can extract these. simply with unzip. But this does not work for all .exe.

  • Pingback: e - extract any archive (commandline) « Martinbaselier’s Blog

  • Dan

    This is a pretty awesome tool. I cannot count the number of times I’ve had to re-read the man pages for the various extraction utilities to get the switches right. I personally commend you and hope this makes it’s way in as a standard addition to most distributions (I currently use SuSE). Props to you Martin!

  • Michael

    Hey Martin,
    I’m using Ubuntu 8.10 and followed your installation commands. I keep getting an error when trying to extract an arc archive.
    Error is “arc: error while loading shared libraries: libgmp.so.3: cannot open shared object file: No such file or directory”.
    Any thoughts on that?
    Thanks

  • http://martin.ankerl.com/ Martin Ankerl

    Hi Michael, sorry but I have no idea. Try googling for this error message, maybe you find the solution. This has nothing to do with e, this seems to be a problem of arc.

  • http://allynbauer.com Allyn

    Excellent. Love to see Ruby in the wild.

  • Erwin

    One problem, just installed Intrepid Ibex (ubuntu 8.10)
    After copying the exact code for the teriminal, you are asked if you want to continue y/n. If I say Y, it says abort. and doesn’t do anything afterwards.

    Erwin

  • http://martin.ankerl.com/ Martin Ankerl

    Hi Erwin, install ruby with “sudo apt-get install ruby” if you have not done this already.

  • Michael

    Awesome tool!
    I have made one adjustment for extracting RPM files.

    I added the -m option to preserve the original ‘pack’ – date

    rules.push [ :type, /^RPM/, "rpm2cpio < %FILE% | cpio -i -m -d --verbose" ]

    THANKS for sharing this powerful utility

  • http://martin.ankerl.com/ Martin Ankerl

    Hi Michael, thanks! I have updated the tool with your suggestion and made a new release. Now also with a nanozip extraction.

  • Michael

    Cool :-)

  • http://splitside.net John Murray

    Hey, I am a student at Northern Kentucky University and I wanted to use your script on a web crawler program for my research. I wanted to get your approval before using the script as it may be distributed later in the future. I will of course give you full credit for the use of your script. If you can send me an e-mail letting me know, that would be much appreciated! By the way, the script is very useful!

  • http://martin.ankerl.com/ Martin Ankerl

    Hi John, sure you can use it.

  • http://toto-share.com toto

    very useful script. Very difficult to remember all program and parameter. Your simplify our problem with this tool. Thank for share this e program :)