Linux – unzip how to trim top directories

linuxzip

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.

Best Answer

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

Related Question