How to update one file in a zip archive

后端 未结 10 1225
心在旅途
心在旅途 2020-12-02 16:16

Is it possible to replace a file in a zip file without unzipping deleting the old file adding the new file and rezipping it back?

Reason is I have a zip file which i

10条回答
  •  佛祖请我去吃肉
    2020-12-02 17:11

    7zip (7za) can be used for adding/updating files/directories nicely:

    Example: Replacing (regardless of file date) the MANIFEST.MF file in a JAR file. The /source/META-INF directory contains the MANIFEST.MF file that you want to put into the jar (zip):

    7za a /tmp/file.jar /source/META-INF/
    

    Only update (does not replace the target if the source is older)

    7za u /tmp/file.jar /source/META-INF/
    

提交回复
热议问题