34

How do I delete a directory from a zip file using a bash script?

3 Answers 3

35

From man zip:

      zip -d foo foo/tom/junk foo/harry/\* \*.o

will  remove  the  entry  foo/tom/junk,  all  of  the  files  that  start  with
foo/harry/,  and  all  of  the files that end with .o (in any path).

If that doesn't help, can you provide some details about the commands you've tried and the output?

29

If you want to delete all files from a specific dir, you could do this:

zip --delete file.zip "assets/*"
0

Maybe it could be done with a script, but in command line if you want to delete a directory from the zip file, make sure the directory is empty. If the directory is not empty, then first delete all the files from the directory. Then you can able to delete the directory.

1
  • Can you give command lines? Please edit your answer
    – damadam
    Nov 22, 2019 at 13:00

You must log in to answer this question.

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