Error while unzipping a file in shell script.

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

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)

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

3

5 Answers

Use 7z from p7zip-full package in Debian:

$ 7z x test.zip

0

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

$ brew install p7zip 

use this to unzip a file

$ 7z x file.zip 

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.

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).

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 .)

Try installing 7z sudo apt-get install p7zip-full and then extract the file with it.

For example:

7z x datafile.zip -aoa -p$3CR37

Argument -p****** is the password.

-aoa allows extraction over any existing local files.

You need install 7z

  • Search the package
  • $ apt search p7zip .... .... p7zip/focal,now 16.02+dfsg-7build1 amd64 [已安装] 7zr file archiver with high compression ratio p7zip-full/focal 16.02+dfsg-7build1 amd64 7z and 7za file archivers with high compression ratio ...
  • You can see the p7zip-full/focal 16.02+dfsg-7build1 amd64 is the currect one
  • $ sudo apt install p7zip-full, now you can run 7z command,for help 7z --help
  • Decompress file with 7z x test.zip -p**** -p Switches doesn't have write if the file has no password
  • ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJoaXFraGh%2BeoWOnqmrp6JixKm1y55krqaqnr2xtc2gZJpllp65pnnIp2SsoJWhuW6%2Fwqugqaxdo7KmsIypomabn6K9osCMr2xmaV2Yrq95w6hkr2w%3D

     Share!

    You Might Also Like