解决unzip不能解压windows创建的zip文件问题

Mac OS X下默认带有unzip命令行工具,但在解压windows下创建的一些zip文件时有可能会出现如下问题:

$ unzip 19.zip
Archive:  19.zip
   skipping: QuestionImages\content\images\shuxueyunyong\MC_40183_stem.png  need PK compat. v4.5 (can do v2.1)
   skipping: QuestionImages\content\images\tuxingtuili\PR_20018_A.png  need PK compat. v4.5 (can do v2.1)
   skipping: QuestionImages\content\images\tuxingtuili\PR_20018_B.png  need PK compat. v4.5 (can do v2.1)
   skipping: QuestionImages\content\images\tuxingtuili\PR_20018_C.png  need PK compat. v4.5 (can do v2.1)
   skipping: QuestionImages\content\images\tuxingtuili\PR_20018_D.png  need PK compat. v4.5 (can do v2.1)
   skipping: QuestionImages\content\images\tuxingtuili\PR_20018_stem.png  need PK compat. v4.5 (can do v2.1)
   skipping: QuestionImages\content\images\tuxingtuili\PR_20065_A.png  need PK compat. v4.5 (can do v2.1)
   skipping: QuestionImages\content\images\tuxingtuili\PR_20065_B.png  need PK compat. v4.5 (can do v2.1)

根据错误信息need PK compat. v4.5 (can do v2.1)从网上查询建议使用p7zip解压,如下:

$ brew install p7zip
$ 7za x 19.zip
$ ll
-rw-r--r--  1 shawyeok  wheel     6351 Jul 20 11:35 QuestionImages\content\images\shuxueyunyong\MC_40183_stem.png
-rw-r--r--  1 shawyeok  wheel      533 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20018_A.png
-rw-r--r--  1 shawyeok  wheel      649 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20018_B.png
-rw-r--r--  1 shawyeok  wheel      758 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20018_C.png
-rw-r--r--  1 shawyeok  wheel      687 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20018_D.png
-rw-r--r--  1 shawyeok  wheel     7034 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20018_stem.png
-rw-r--r--  1 shawyeok  wheel     1870 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20065_A.png
-rw-r--r--  1 shawyeok  wheel     1635 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20065_B.png
-rw-r--r--  1 shawyeok  wheel     1827 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20065_C.png
-rw-r--r--  1 shawyeok  wheel     1720 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20065_D.png
-rw-r--r--  1 shawyeok  wheel     2111 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20065_stem.png
-rw-r--r--  1 shawyeok  wheel      429 Jul 20 11:35 QuestionImages\content\images\tuxingtuili\PR_20085_A.png

通过上面结果可以看到由于文件分隔符的问题,导致解压出的文件的路径直接变成了文件名的一部分。
上面两个问题主要原因是unzip版本较低导致,安装较新版本即可,如下:

$ sudo brew install homebrew/dupes/unzip
$ sudo ln -sf /usr/local/Cellar/unzip/6.0_2/bin/funzip /usr/local/bin/funzip
$ sudo ln -sf /usr/local/Cellar/unzip/6.0_2/bin/unzip /usr/local/bin/unzip
$ sudo ln -sf /usr/local/Cellar/unzip/6.0_2/bin/unzipsfx /usr/local/bin/unzipsfx
$ sudo ln -sf /usr/local/Cellar/unzip/6.0_2/bin/zipgrep /usr/local/bin/zipgrep
$ sudo ln -sf /usr/local/Cellar/unzip/6.0_2/bin/zipinfo /usr/local/bin/zipinfo

$ sudo cp -r /usr/local/Cellar/unzip/6.0_2/share/* /usr/share/

参考资料:

  • http://www.info-zip.org/UnZip.html
  • http://brew.sh

你可能感兴趣的:(工具)