Ubuntu 資料一覧

破損したzipファイルから一部を取り出す

2019/05/23更新

対応バージョン: 18.04

破損したzipファイルは内包されているファイルのうち整合性が取れているものがあればそのファイルだけ取り出すことができる。

zipコマンドのバージョン
$ zip --version
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.
:
破損状態確認
$ unzip a.zip
Archive:  a.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of a.zip or
        a.zip.zip, and cannot find a.zip.ZIP, period.
破損状態のzipファイルから整合性の取れる部分のみを取り出す
$ zip -FF a.zip --out b.zip
Fix archive (-FF) - salvage what can
	zip warning: Missing end (EOCDR) signature - either this archive
                     is not readable or the end is damaged
Is this a single-disk archive?  (y/n): y
  Assuming single-disk archive
Scanning for entries...
 copying: a.txt  (234 bytes)
zipファイル解凍
$ unzip b.zip
Archive:  b.zip
 extracting: a.txt                   

参考サイト