unzip how to trim top directories

I have a zip archive. The unzip -l myarchive.zip command gives this listing:

top/subtop/files/1.txt
top/subtop/files2/2.txt
etc

The root folders are top/subtop for all files. How to extract those files without the two top/subtop folders?

E.g. when I am in /home/myuser/public_html directory, files/1.txt and files2/2.txt shoud be extracted directly to that directory.

I tried unzip myarchive.zip top/subtop/* but it created top/subtop directories anyway.


Solution 1:

Unfortunately, you can't. Your only real option is to just move them after they are extracted.

Solution 2:

You might want to try the tar command, which has a --strip-components feature and can operate on zip files.