bash 在 shell 脚本中解压缩文件时出错。- 需要PK兼容。v5.1(可以做v4.6)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28383199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 12:20:21  来源:igfitidea点击:

Error while unzipping a file in shell script. - need PK compat. v5.1 (can do v4.6)

bashshellubuntushubuntu-14.04

提问by Tejus Prasad

I'm using unzip test.zipin a Shell script. But while executing this line i get an error

unzip test.zip在 Shell 脚本中使用。但是在执行这一行时我得到一个错误

Archive:  test.zip
   skipping: hello.pdf                need PK compat. v5.1 (can do v4.6)

Even if i try to run this single command from the terminal in ubuntu it throws the same error need PK compat. v5.1 (can do v4.6)

即使我尝试从 ubuntu 的终端运行这个单一的命令,它也会抛出同样的错误 need PK compat. v5.1 (can do v4.6)

Uninstalling and reinstalling unzip also didn't work. Alternately I had to install p7zip-fullto unzip the test.zip file. How to fix this and use unzipin the shell script??

卸载并重新安装 unzip 也没有用。或者,我必须安装p7zip-full以解压缩 test.zip 文件。如何解决这个问题并unzip在 shell 脚本中使用?

采纳答案by eckes

I think it is "normal" that info-zip's unzip6.0 can only work with ZIP Entries which use the 4.6 version. This describes the features needed to uncompress it. The latest addition in unzip 6.0 is bzip2, which is represented in version 4.6. The 5.1 version you get when you use the (AES) strong encryption feature.

我认为 info-zip 的 unzip6.0 只能与使用 4.6 版本的 ZIP 条目一起使用是“正常的”。这描述了解压缩它所需的功能。unzip 6.0 中最新添加的是 bzip2,它在 4.6 版中有表示。使用 (AES) 强加密功能时获得的 5.1 版本。

You need to use alternative tools like the mentioned 7zip (or the commercial pkunzip) to unpack those files. When you can influence the creation process, then play around with the features you use and which not (i.e. do not ask for strong password encryption if you want to be compatible with legacy infozip tool).

您需要使用上述 7zip(或商业 pkunzip)等替代工具来解压这些文件。当您可以影响创建过程时,请尝试使用您使用的功能和不使用的功能(即,如果您想与旧的 infozip 工具兼容,请不要要求强密码加密)。

And yes, this is somewhat unfortunate. And I think the unzip is ported to so many target platforms, that nobody wants to work on it anymore .)

是的,这有点不幸。而且我认为解压文件被移植到如此多的目标平台上,以至于没有人愿意再使用它了。)

回答by Nicolás Wolovick

Use 7zfrom p7zip-fullpackage in Debian:

在 Debian 中7zp7zip-full包中使用:

$ 7z x test.zip

$ 7z x test.zip

回答by AshuGG

You can use p7zip to perform the required action. Use brew to install it.

您可以使用 p7zip 来执行所需的操作。使用 brew 安装它。

$ brew install p7zip

use this to unzip a file

使用它来解压缩文件

$ 7z x file.zip