如何安装7zip,以便可以在OS X的Terminal上运行它


Answers:


327

要使用Homebrew安装p7zip,请首先更新您的公式,以确保获得最新的公式。brewp7zip

$ brew update

使用Homebrew安装p7zip

$ brew install p7zip

sputnik目录中的所有文件添加到压缩文件中heed.7z

$ 7z a heed.7z sputnik

解压缩heed.7z

$ 7z x heed.7z

10
对于macports同样:sudo port install p7zip没问题
Alan Blount 2014年

1
@AlanBlount感谢您为MacPorts添加说明。
Troy Harvey

1
@ pal4life检查您的地窖目录上的权限。
Troy Harvey

1
@MaciekSemik示例文件名。
Sridhar Katakam

2
我不得不来到这里来发现命令不是p7zip,而是7z ...
MikeP

39

7-zip下载页面上,有多个OS X选项。不幸的是,它们似乎带有GUI,或者暂时不可用。


您可以下载p7zip。

p7zip是Unix / Linux的7-Zip的命令行版本,由独立开发人员制作

它作为Linux二进制文件和Sourceforge上的源代码形式分发。

下载源代码,然后make在将存档解压缩到的文件夹中运行。它会自动7za为您的操作系统构建。您可能需要Xcode及其命令行工具才能起作用。

$ cd Downloads/p7zip_9.20.1
$ make
[...]
$ cd bin
$ ls
7za
$ ./7za 

7-Zip (A) [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=de_DE.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

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

<Commands>
  a: Add files to archive
  b: Benchmark
  d: Delete files from archive
  e: Extract files from archive (without using directory names)
  l: List contents of archive
  t: Test integrity of archive
  u: Update files to archive
  x: eXtract files with full paths
<Switches>
  -ai[r[-|0]]{@listfile|!wildcard}: Include archives
  -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
  -bd: Disable percentage indicator
  -i[r[-|0]]{@listfile|!wildcard}: Include filenames
  -m{Parameters}: set compression Method
  -o{Directory}: set Output directory
  -p{Password}: set Password
  -r[-|0]: Recurse subdirectories
  -scs{UTF-8 | WIN | DOS}: set charset for list files
  -sfx[{name}]: Create SFX archive
  -si[{name}]: read data from stdin
  -slt: show technical information for l (List) command
  -so: write data to stdout
  -ssc[-]: set sensitive case mode
  -t{Type}: Set type of archive
  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
  -v{Size}[b|k|m|g]: Create volumes
  -w[{path}]: assign Work directory. Empty path means a temporary directory
  -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
  -y: assume Yes on all queries

$ ./7za a 7za.7z 7za 

7-Zip (A) [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=de_DE.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)
Scanning

Creating archive 7za.7z

Compressing  7za      

Everything is Ok

$ ls
7za    7za.7z

1
在“ make”之前,我必须发出命令“ cp makefile.macosx_64bits makefile.machine”
chrisinmtown

15

如果仅需要解压缩档案,则unar(Unarchiver的命令行版本)也支持7zip。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.