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.

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.

  • This does not work for me; the top directory in the zip file is copied to the destination directory. – August Karlstrom Dec 1 '11 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.