53

Looking to unpack a bunch of files.7z via terminal.

Is there a command-line tool built in, available or I shall install an application that comes with a graphical interface?

80

You can install p7zip with Homebrew. So

% brew install p7zip
% 7za x myfiles.7z

Installing Homebrew as @EraserPencil suggested makes sense as the OP might need more programs in the future, which would be at his fingertips then. You can install Homebrew with

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

It should be noted there is 7z e as well but as commented by @Qback, this does almost never do what you want if you have subdirectories in the archive.

  • I have 7zip installed as well. Unfortunately, it said that the archive is damaged and failed to extract the file. Tried installing 7za and it worked like a charm. – Xonshiz May 15 at 12:20
12

The command line version of Unarchive can extract .7z files.

7

MacOS does not handle the .7z format natively.

The UnArchiver is my favourite tool for handling .7z and many other formats. It is available as both an application and a command line tool if that is how you prefer to operate.

1

If you don't want to install homebrew, you can install keka (which is an excellent gui for (un)compressing btw) and then link to the included version of p7zip found at Keka.app/Contents/Resources/keka7z

In order to make it function from the command line, I symlinked it into my /usr/local/bin

> ln -s /Applications/Keka.app/Contents/Resources/keka7z /usr/local/bin/7z
> 7z -h

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,4 CPUs x64)
Modified by aONe for Keka

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]
0

We also found another totally free GUI solution that can run on macOS from this other similar question

Keka - the FREE macOS file un/archiver.

0

You can install P7ZIP from Rudix. You don't have to install the Rudix ecosystem.

-4

Because you are familiar with CLI and coming from a Linux background, you could try Installing GNU-tar on Mac

You'd first need to install Homebrew,

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then run brew install gnu-tar. Think of brew as the yum, or apt-get equivalent.

Then you can use gtar on your Mac.

# on Mac
$ gtar czvf example.tar.gz example
example/
example/bla.txt

# send it to CentOS
# login to CentOS

$ tar xzvf example.tar.gz
example/
example/bla.txt
  • 3
    AFAIK tar does not extract/unpack .7z files. – user3439894 Nov 30 '17 at 3:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .