解凍は、単一の圧縮アーカイブを取得し、その中からファイルとフォルダーを抽出するプロセスです。既に zip ファイルがあるため、最初にファイルを抽出する必要があります。これは圧縮解除とも呼ばれます。
zip ファイルを解凍するコマンドは、次のように unzip です:
% unzip --help UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send bug reports using http://www.info-zip.org/zip-bug.html; see README for details. Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir] Default action is to extract files in list, except those in xlist, to exdir; file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage). -p extract files to pipe, no messages -l list files (short format) -f freshen existing files, create none -t test compressed archive data -u update files, create if necessary -z display archive comment only -v list verbosely/show version info -T timestamp archive to latest -x exclude files that follow (in xlist) -d extract files into exdir modifiers: -n never overwrite existing files -q quiet mode (-qq => quieter) -o overwrite files WITHOUT prompting -a auto-convert any text files -j junk paths (do not make directories) -aa treat ALL files as text -C match filenames case-insensitively -L make (some) names lowercase -X restore UID/GID info -V retain VMS version numbers -K keep setuid/setgid/tacky permissions -M pipe through "more" pager See "unzip -hh" or unzip.txt for more help. Examples: unzip data1 -x joe => extract all files except joe from zipfile data1.zip unzip -p foo | more => send contents of foo.zip via pipe into program more unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
unzip コマンドの実行中に以下のエラーが発生した場合:
unzip: command not found
選択したディストリビューションに従って unzip パッケージをインストールしてみてください。
分布 | コマンド |
---|---|
OS X | brew install unzip |
Debian | apt-get install unzip |
Ubuntu | apt-get install unzip |
アルパイン | apk 追加解凍 |
Arch Linux | pacman -S unzip |
カリ Linux | apt-get install unzip |
CentOS | yum install unzip |
Fedora | dnf install unzip |
Raspbian | apt-get install unzip |
解凍コマンドの例
1. zip ファイルの整合性をテストする:
$ unzip -t test.zip
ダウンロードしたファイルにエラーがあった場合は、もう一度ダウンロードしてみてください。アーカイブでエラーが検出されなかった場合は、次に進むことができます。
2. zip ファイルの内容の一覧表示:
$ unzip -l test.zip
3. zip ファイルを抽出します (複数のファイルの場合は、ファイル パスをスペースで区切ります):
$ unzip file(s)
3. 指定されたパスに zip ファイルを抽出します:
$ unzip compressed_file(s) -d path/to/put/extracted_file(s)
4. 抽出されたファイル名とともに、ファイルの内容を stdout に抽出します。
$ unzip -c file.zip
5. Windows で作成された zip ファイルを解凍します。これには、非 ASCII (中国語または日本語の文字など) のファイル名を持つファイルが含まれています:
$ unzip -O gbk file.zipzip:コマンドが見つかりません