Unzip with the Pipe Viewer

I'm trying to use Pipe Viewer (pv) while extracting files from zip archive.

Now I'm using

unzip -o -q myfile.zip -d test

So I tried something like (solution seen for tar)

pv myfile.zip | unzip -o -q - -d test

But it's not working. What would be the correct syntax?

2 Answers

The source of the problem is not the syntax, but the build-in difference between tar and zip.

The problem with submitting zip file via pipe is based on zip design

A directory is placed at the end of a .ZIP file. This identifies what files are in the .ZIP and identifies where in the .ZIP that file is located. This allows .ZIP readers to load the list of files without reading the entire .ZIP archive

When providing zip via pipe - the directory will be accessed only after the entire file will be supplied by the pipe, hence pv should be completed before unzip should start - which cause the failure you are facing.

1

Take bsdtar for using unzip via pipe. Example:

$ sudo apt install libarchive-tools
$ wget -qO- |sudo bsdtar -xvf- -C /usr/local/share/fonts/
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like