zip

提供: セキュリティ
2014年7月20日 (日) 18:07時点におけるDaemon (トーク | 投稿記録)による版 (zip ファイルの情報を調べる)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索
スポンサーリンク

Unixzip コマンドは、ZIP ファイルを作成するコマンドです。ディレクトリを再帰的にzipにまとめることができます。ZIPファイルを展開(解凍)するには、unzipコマンドを使用します。

読み方

zip
じっぷ

概要

Unixzip コマンドは、ファイルを ZIP で 圧縮(アーカイブ)するツールです。

インストール

zipのインストール方法です。

FreeBSDにインストールする場合

ports コレクションからインストールする場合

cd /usr/ports/archivers/zip
sudo make install clean

pkgコマンドでインストールする場合

sudo pkg install zip

portmasterコマンドでインストールする場合

sudo portmaster -y -d /usr/ports/archivers/zip

portinstallコマンドでインストールする場合

sudo portinstall /usr/ports/archivers/zip

インストール

unzipのインストール方法です。

FreeBSDにインストールする場合

ports コレクションからインストールする場合

cd /usr/ports/archivers/unzip
sudo make install clean

pkgコマンドでインストールする場合

sudo pkg install unzip

portmasterコマンドでインストールする場合

sudo portmaster -y -d /usr/ports/archivers/unzip

portinstallコマンドでインストールする場合

sudo portinstall /usr/ports/archivers/unzip

使い方

コマンドラインオプション

% zip -h
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
  -h2  show more help

普通の zip ファイルの作成

a.zip ファイルを作成します。

zip a.zip tmp/a.txt tmp/b.txt tmp/c.txt

ディレクトリのファイルを再帰的に zip にする

$HOME/foo の内容を /tmp/foo.zip にまとめる例です。

cd $HOME/foo
zip -r /tmp/foo.zip .

パスワード付き zip ファイルの作成

zip --encrypt --password test e.zip tmp/a.txt tmp/b.txt tmp/c.txt


コメント付き zip ファイルの作成

コメントをつける場合は、-c オプションを利用します。

zipnote コマンドで、コメントを確認できます。

% zip -c a.zip tmp/a.txt
  adding: tmp/a.txt (stored 0%)
Enter comment for tmp/a.txt:
hoge
% zipnote a.zip
@ tmp/a.txt
hoge
@ (comment above this line)
@ (zip file comment below this line)
% strings a.zip
tmp/a.txtUT
~Qux
tmp/a.txtUT
~Qux
hogePK

zip ファイルの情報を調べる

FreeBSDの場合、zipinfoは、unzipのパッケージで提供されます。

% zipinfo a.zip
Archive:  a.zip
Zip file size: 172 bytes, number of entries: 1
-rw-r--r--  3.0 unx        0 bx stor 13-Apr-30 00:15 tmp/a.txt
1 file, 0 bytes uncompressed, 0 bytes compressed:  0.0%
% zipinfo e.zip
Archive:  e.zip
Zip file size: 544 bytes, number of entries: 3
-rw-r--r--  3.0 unx        0 BX stor 13-Apr-30 00:15 tmp/a.txt
-rw-r--r--  3.0 unx        0 BX stor 13-Apr-30 00:15 tmp/b.txt
-rw-r--r--  3.0 unx        0 BX stor 13-Apr-30 00:15 tmp/c.txt
3 files, 0 bytes uncompressed, 0 bytes compressed:  0.0%

unzipの使い方

コマンドラインオプション

usage: unzip [-aCcfjLlnopqtuvZ1] [-d dir] [-x pattern] zipfile

zipファイルを解凍する

$ unzip foo.zip

関連項目




スポンサーリンク