2013-02-08 10:35:49 +0000 2013-02-08 10:35:49 +0000
194
194

如何安装7zip,以便在OS X上从终端机上运行?

我希望能够在Mac上通过命令行运行7zip。有人知道如何设置吗?

答案 (3)

339
339
339
2013-10-29 20:26:57 +0000

要使用 Homebrew 安装 p7zip ,首先要更新你的 brew公式,以确保你得到最新的 p7zip

$ brew update

使用 Homebrew 安装 p7zip:

$ brew install p7zip

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

$ 7z a heed.7z sputnik

解压 heed.7z: 0x6&:

$ 7z x heed.7z

解压

42
42
42
2013-02-08 10:49:31 +0000

7-zip的下载页面,有几个OS X的选项。不幸的是,他们似乎是与GUI,或目前不可用。


你可以下载p7zip。

p7zip是7-Zip for Unix/Linux的命令行版本,由一个独立开发者制作

它以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
16
16
16
2013-02-08 12:57:14 +0000

如果你只需要解压压缩文件, unar (The Unarchiver的命令行版本)也支持7zip。