Linux – unzip into subdirectory in Linux

compressionlinux

I have a zip file, and would like to unzip a subdirectory of it to another subdirectory, overwriting all existing files. How can this be done in Linux?

Example:
The zip file hi.zip has a "me" folder in it. I would like to extract only the files/folders inside "me" to a folder on the system named "/home/zzz/". However, "/home/zzz/" already has files in it with the same names. I'd like to replace those with the new ones in the hi.zip file.

Best Answer

unzip -o hi.zip me/\* -d /home/zzz

should do the trick. I suggest you test it first to make sure you don't overwrite the wrong files.