Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a shell script that unzips a ZIP file into an existing hierarchy of files, potentially overwriting some of the files.

The problem is that the unzip command asks for confirmation:
replace jsp/extension/add-aspect.jsp? [y]es, [n]o, [A]ll, [N]one, [r]ename: y

Is there an option to force unzip to overwrite the files?

share|improve this question
up vote 94 down vote accepted

According to you can use the -o option to overwrite files:

unzip -o /path/to/

Note that -o, like most of unzip's options, has to go before the archive name.

share|improve this answer
Indeed! Thanks a lot! – Nicolas Raoul Jan 26 '10 at 10:36
e.g: unzip -o ZIP_PATH, works as a modifier. – bonzofenix Jul 21 '14 at 22:35
-o option should be used before any other arguments. Example: unzip -o /path/to/ -d /destination_dir – FelikZ May 28 '15 at 8:48
@FelikZ Thanks for the detail, I added your (stripped down) example to the answer – foraidt May 28 '15 at 11:57

gunzip -f /path/to/ will also force to overwrite

share|improve this answer
gunzip cannot unzip a regular .zip file containing multiple files. – poolie Jan 23 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .