e – Extract Any Archive

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.

41 Responses to “e – Extract Any Archive”

  1. damentz on August 12th, 2006 4:26 am

    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

  2. shevegen on August 12th, 2006 12:48 pm

    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?

  3. martinus on August 12th, 2006 1:39 pm

    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 :-)

  4. redemption in a blog on August 13th, 2006 5:46 pm

    [...] Program

  5. Will on August 14th, 2006 8:15 pm

    You might want to change extrationSuccess to extractionSuccess.

  6. martinus on August 14th, 2006 8:59 pm

    thanx Will, I fixed that.

  7. Aaron on August 16th, 2006 11:43 pm

    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.

  8. csabahenk on August 17th, 2006 7:06 pm

    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.

  9. Anonymous on August 18th, 2006 10:42 am

    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 :-)

  10. Programming Kung Fu » Program “e” updated on December 10th, 2006 12:26 pm

    [...] I have updated the extraction utility e with several new extraction rules. It now contain 28 different rules for extracting archives. This means it can extract zip, rar, 7zip, gzip, bzip2, rpm, deb, cab, arj, ace, ppmd, lzo, tar.bz2, tar.gz, tlz, tar.lzma, ar, cpio, dar, uharc, zzip, and some more with a single common interface if you have the tools on your PC. Get it here. [...]

  11. “e” — New Release of Extract Any Archive — Martin Ankerl on February 25th, 2007 10:34 am

    [...] and some files are not extractable, e continuous to extract the other files and prints an error message with all the failed files when it has finished. More info and download of e is here. [...]

  12. Mike on March 25th, 2007 9:56 pm

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

  13. La otra bola de cristal » Blog Archive » Otra manera de descomprimir rápida y fácilmente on July 9th, 2007 10:05 pm

    [...] Echadle un ojo porque es también bastante interesante: e — Extract Any Archive. [...]

  14. Linux Music » Blog Archive » Descomprime Archivos De Forma Chupá En Linux Con E on July 10th, 2007 7:19 am

    [...] e Extract Any Archive [...]

  15. links for 2007-11-13 « Where Is All This Leading To? on November 13th, 2007 12:31 am

    [...] e — Extract Any Archive by Martin Ankerl (tags: extraction compression linux ruby programming freeware opensource extract tools ubuntu script) [...]

  16. christy donnelly on November 15th, 2007 9:14 pm

    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.

  17. Martin Ankerl on November 15th, 2007 9:20 pm

    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!

  18. C D on November 15th, 2007 10:22 pm

    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.

  19. Martin Ankerl on November 15th, 2007 10:37 pm

    move it to /usr/local/bin:

    sudo mv e /usr/local/bin
  20. C D on November 15th, 2007 10:54 pm

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

  21. Jordan_U on November 22nd, 2007 10:57 am
  22. Sam Jones on January 8th, 2008 8:11 pm

    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 :-)

  23. Martin Ankerl on January 8th, 2008 10:59 pm

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

  24. Matt Chamberlain on February 23rd, 2008 9:45 pm

    Thanks so much! Great tool!

  25. Carra on February 24th, 2008 7:35 am

    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. ;-)

  26. Martin Ankerl on February 24th, 2008 3:01 pm

    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

  27. e:可以解包多种存档格式的小工具 | LinuxDig on April 25th, 2008 8:56 am

    [...] e 是一个使用 Ruby 语言写成的小工具,它可以对下列存档文件格式执行解包操作:zip、rar、7zip、gzip、bzip2、rpm、deb、cab、arj、ace、ppmd、lzo、tar.bz2、tar.gz、tlz、tar.lzma、ar、cpio、dar、uharc、zzip 等等,其支持的格式可谓非常广泛。 [...]

  28. info_tech_guy on September 29th, 2008 12:50 am

    /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

  29. Martin Ankerl on September 29th, 2008 6:15 am

    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.

  30. e - extract any archive (commandline) « Martinbaselier’s Blog on December 18th, 2008 7:48 pm

    [...] e – extract any archive (commandline) By martinbaselier If you like the cli, this little ruby-script is ideal: e [...]

  31. Dan on January 15th, 2009 5:58 pm

    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!

  32. Michael on February 6th, 2009 8:55 pm

    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

  33. Martin Ankerl on February 6th, 2009 10:48 pm

    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.

  34. Allyn on February 19th, 2009 5:44 am

    Excellent. Love to see Ruby in the wild.

  35. Erwin on April 2nd, 2009 9:32 am

    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

  36. Martin Ankerl on April 2nd, 2009 4:47 pm

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

  37. Michael on June 25th, 2009 8:52 pm

    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

  38. Martin Ankerl on June 25th, 2009 9:13 pm

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

  39. Michael on June 25th, 2009 9:41 pm
  40. John Murray on November 3rd, 2009 5:05 am

    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!

  41. Martin Ankerl on November 29th, 2009 2:57 pm

    Hi John, sure you can use it.

Leave a Reply