7z

圧縮と転送

書き方

7z <a|x|l> <archive.7z> [files]

最初に a(追加)・x(パスのまま展開)・e(平らに展開)・l(一覧)といった語を置いて使い、.7z だけでなく zip・tar・rar も読め、圧縮率も高いほうです。出力先は `-o` に空白を入れず続けて書き、名前まで隠すには `-p` に `-mhe=on` を添えます。

よく使うオプション

オプション意味
aAdd or create.
xExtract keeping the stored directory structure.
eExtract everything into one directory, flattening paths.
lList the contents.
-o<dir>Output directory, written with no space after -o.
-p<password>Password. Add -mhe=on to encrypt the file names too.
-mx=9Maximum compression.
-t7z / -tzipChoose the output format.

7z a -mx=9 backup.7z ./data

A tightly compressed archive.

7z x archive.7z -o/tmp/out

Extract with the folder structure intact.

7z a -p -mhe=on secret.7z ./docs

Encrypt the contents and the file names, with a prompted password.

まとめることと縮めることは別の仕事です。tar がまとめ、gzip が縮め、.tar.gz はその両方です。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. 7z は何をしますか。

最初に a(追加)・x(パスのまま展開)・e(平らに展開)・l(一覧)といった語を置いて使い、.7z だけでなく zip・tar・rar も読め、圧縮率も高いほうです。出力先は `-o` に空白を入れず続けて書き、名前まで隠すには `-p` に `-mhe=on` を添えます。

Q. どう打ちますか。

7z <a|x|l> <archive.7z> [files] — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは8個です。全部は man 7z にあります。このコマンドは圧縮と転送の仲間です。

関連するコマンド

man ページ: man 7z