Is there some command line tool which allows extracting files from most known archive types? Something like StuffIt Expander, but without gui.
6 Answers
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,
unarandlsar, 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).
You can use brew install unar or brew install atool and then:
unar archive.gz # or atool -x archive.gz 2If you happen to use Homebrew, you can install atool and extract many archive types like so:
brew install atool atool -x archive.anything Assuming the corresponding external programs are available on your system, it can handle:
.tar.gz, .tgz, .tar.bz, .tbz, .tar.bz2, .tbz2, .tar.Z, .tZ, .tar.lzo, .tzo, .tar.lz, .tlz, .tar.xz, .txz, .tar.7z, .t7z, .tar, .zip, .jar, .war, .rar, .lha, .lzh, .7z, .alz, .ace, .a, .arj, .arc, .rpm, .deb, .cab, .gz, .bz, .bz2, .gz, .bz, .bz2, .Z, .lzma, .lzo, .lz, .xz, .rz, .lrz, .7z, .cpio
2
atoolis a script for managing file archives of various types (tar, tar+gzip, zip etc).The main command is
aunpackwhich extracts files from an archive. Did you ever extract files from an archive, not checking whether the files were located in a subdirectory or in the top directory of the archive, resulting in files scattered all over the place?aunpackovercomes this problem by first extracting to a new directory. If there was only a single file in the archive, that file is moved to the original directory.aunpackalso prevents local files from being overwritten by mistake.The other commands provided are
apack(to create archives),als(to list files in archives), andacat(to extract files to standard out). Asatoolinvokes external programs to handle the archives, not all commands may be supported for a certain type of archives.
atoolidentifies archives by their file extension. Sometimes this is not possible - for instance rar archives usually have varying numeric file extensions. In those cases whenatoolcan't identify the format,fileis used instead. (atoolcan be configured not to use file.)
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.
4For 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.
Arc: Cross-Platform Archiver (CLI)
Arc handles a bunch of common formats and is written in pure Go, so it works on Linux and Windows as well.
See for cross-platform installer or for the Go library.
curl -sS | bash arc unarchive example.tar.xz Supported formats (as of v3.5.0)
The format of the archive is determined by its file extension*. Supported extensions: .zip .tar .tar.br .tbr .tar.gz .tgz .tar.bz2 .tbz2 .tar.xz .txz .tar.lz4 .tlz4 .tar.sz .tsz .zst .tar.zst .rar (open only) .bz2 .gz .lz4 .sz .xz