2

So far this thread (Extract only a specific file from a zipped archive to a given directory) has helped me tremendously as I was able to generate a file list of all the files in the archive, using:

unzip -l X201SC21041496-Z01-F002.zip

and even look into a specific file that was also compressed, using:

unzip -p X201SC21041496-Z01-F002.zip X201SC21041496-Z01-F002/rawdata/G_M0_2.fq.gz | gunzip -c | head

However, there are also other .zip files in the first .zip file and I want to get a list of that and then potentially look at some of those files without having to unzip the entire thing. I have tried several things:

unzip -p X201SC21041496-Z01-F002.zip X201SC21041496-Z01-F002/Result_X201SC21041496-Z01-F002_Canis_lupus_familiaris.zip | unzip -l

But then I just get referred to the unzip manual (which, to be fair, I need). Or:

unzip -pl X201SC21041496-Z01-F002.zip X201SC21041496-Z01-F002/Result_X201SC21041496-Z01-F002_Canis_lupus_familiaris.zip

Which seemed to list stuff, but then just spit out garbage. I have now resorted to extracting the archive from the archive to my external (using unzip with the -j and -d flags as suggested above, see below) and hoping that I'll be able to navigate that archive from there. But, there surely is a better way?

unzip -j "X201SC21041496-Z01-F002.zip" "X201SC21041496-Z01-F002/Result_X201SC21041496-Z01-F002_Canis_lupus_familiaris.zip" -d "/Volumes/Elements_of_Elise/Postdoc_VI_UU/Qingkang/"

Apologies in advance if I am not using the correct terminology or notation. Very much a rookie, but trying to learn! I did spend a considerably time searching for the answer, but here we are. I am using my terminal on a Macbook pro, BigSur 11.3.1.

Thanks in advance for your help!

1 Answers1

2

As far as I’m aware, this isn’t possible with unzip because it can’t read archives from standard input; however jar, a tool in the Java Development Kits, can:

unzip -p X201SC21041496-Z01-F002.zip X201SC21041496-Z01-F002/Result_X201SC21041496-Z01-F002_Canis_lupus_familiaris.zip |
jar tv
Stephen Kitt
  • 434,908