I have a zip/tar.gz that contain zip files that contains another zip file.
1.zip contains 2.tar.gz and 3.zip. 3.zip contains 4.zip.
I want to extract only 4.zip from 1.zip, I don't want to extract all of files.
How can I do that?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
This is harder than it might seem because
unzip can’t extract from its standard input, so you can’t chain it with pipes. However,
jar can extract ZIP archives from its standard input, as can
funzip (with some limitations).
3.zip only contains
4.zip, or contains
4.zip as its first member, then
funzip can be used:
unzip -p 1.zip 3.zip | funzip > 4.zip
unzip to extract
3.zip’s contents from
1.zip, piping them to standard output, into
funzip which extracts
4.zip’s contents, and writing them to
jar works regardless of the other contents of
unzip -p 1.zip 3.zip | jar x 4.zip
3.zip’s contents into
funzip is shipped alongside
jar is part of the Java Development Kit, e.g.
openjdk-11-jdk-headless on Debian 10.