Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there some command line tool which allows extracting files from most known archive types? Something like StuffIt Expander, but without gui.

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

The Unarchiver has two command line utilities since version 2.5 according to the website:

Supported file formats include Zip, Tar-GZip, Tar-BZip2, RAR, 7-zip, LhA, StuffIt and many other more and less obscure formats. [..] If you have a compressed file that The Unarchiver does not open, please post a bug on the bug tracker, and include the file in question, and I will look into whether it is possible to add support for it!

[..]

There are now two command-line utilities available, unar and lsar, which can be used to unpack and list archives, respectively. They are still in development and not really feature-complete, but they should work. These are available as precompiled binaries for both OS X and Windows on the download page, and can also be built on Linux.

To download the command line tools (not included in the regular The Unarchiver download!), go to the project's google code downloads page and select unar0.2.zip (works as of September 20, 2010).

share|improve this answer
    
Nice! And it supports many formats, just like asked for. –  Arjan Sep 19 '10 at 17:26
    
I can't find CLI there. –  tig Sep 19 '10 at 20:46
1  
tig: You mean you were not able to click on "download page" in the second paragraph nicely quoted by Arjan above and on "unar0.2.zip" there? Because it works fine for me. –  Daniel Beck Sep 20 '10 at 3:42
    
@tig, following the link Daniel referenced, see "unar0.2.zip, unar and lsar command-line utilities for Mac OS X 0.2 (beta version)". Yes, odd that a creator of unzip-software distributes its own software in zip format. ;-) After unzipping, there is a little bit of help using ./unar --help and ./lsar --help –  Arjan Sep 20 '10 at 17:27
    
added download information to the reply –  Daniel Beck Sep 20 '10 at 17:52
show 2 more comments

Try 7-Zip. In addition to its own native format (.7z) it can handle the following extensions: ZIP, gzip, bzip2, tar and, in betas for version 9, xz. It can also decompress (only) in the following formats: ARJ, CAB, CHM, cpio, DEB, DMG, HFS, ISO, LZH, LZMA, MSI, NSIS, RAR, RPM, UDF, WIM, XAR and Z.

A Windows command line version 7za.exe is included. For other platforms, a POSIX version named p7zip is available from the P7ZIP SourceForge project, and some of those ports are also linked from 7-Zip's download page. Unfortunately, the Mac link seems broken, so for OS X, either build it yourself or use MacPorts.

EDIT: For non-Windows versions go to the Downloads page. There you can find the source as well as pre-compiled binaries.

share|improve this answer
    
Windows only, as far as I know. The question asks for command line tools for a Mac. –  Arjan Sep 18 '10 at 12:39
3  
@Arjan: found POSIX version p7zip and it there is macport for it –  tig Sep 18 '10 at 13:15
    
@tig, I merged your comment into Joe's answer. However, I do NOT know if p7zip supports all formats that 7-Zip does. If anyone happens to know of a binary download link then let us know. –  Arjan Sep 18 '10 at 13:58
    
Unfortunately, p7zip does not fully handle archives created on mac (with specially named files storing forks and other extra stuff) –  tig Sep 19 '10 at 20:55
add comment

For the compression and archiving types that Mac OS X knows natively, you can just use open, and it'll invoke "Archive Utility" (formerly BOMArchiveHelper), just like double-clicking it from the Finder would have. This works for [pk]zip, gzip, bzip, bzip2, tar, pax, cpio, compress (.Z), etc. etc.

If you have apps installed that know how to unarchive other formats, and they have registered for those file extensions or magic(5) values, then the open command will launch those apps to handle those types. Of course you'll probably end up in those apps' GUIs.

share|improve this answer
1  
That is what I am using now, but it has some disadvantages: I can't specify options like extracting to specific folder, application window is popping out (even if I run it with -g, it is still under frontmost window) –  tig Sep 19 '10 at 20:40
add comment

protected by Daniel Beck Aug 29 '12 at 15:19

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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