「zip」の版間の差分

提供: セキュリティ
移動: 案内検索
(ページの作成:「<!-- vim: filetype=mediawiki --> Unixzip コマンドは、ZIP ファイルを作成するコマンドです。 読み方 ;zip:じっぷ __TOC__ ...」)
 
行55: 行55:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
zip --encrypt --password test e.zip tmp/a.txt tmp/b.txt tmp/c.txt
 
zip --encrypt --password test e.zip tmp/a.txt tmp/b.txt tmp/c.txt
 +
</syntaxhighlight>
 +
 +
 +
=== コメント付き zip ファイルの作成 ===
 +
 +
コメントをつける場合は、-c オプションを利用します。
 +
 +
zipnote コマンドで、コメントを確認できます。
 +
 +
<syntaxhighlight lang="bash">
 +
% 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)
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="bash">
 +
% strings a.zip
 +
tmp/a.txtUT
 +
~Qux
 +
tmp/a.txtUT
 +
~Qux
 +
hogePK
 +
</syntaxhighlight>
 +
 +
=== zip ファイルの情報を調べる ===
 +
 +
<syntaxhighlight lang="bash">
 +
% 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%
 
</syntaxhighlight>
 
</syntaxhighlight>
  

2013年4月30日 (火) 01:20時点における版

Unixzip コマンドは、ZIP ファイルを作成するコマンドです。

読み方

zip
じっぷ

概要

Unixzip コマンドは、ファイルを 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

使い方

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

% 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 ファイルの作成

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 ファイルの情報を調べる

% 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%

関連項目