2016-07-29 32 views
1
$(which zip) -r ../data.zip . 

Der Inhalt der Ordner erstellen dynamisch Überstunden zu ändern, die ich getestet habe es zuerst mit einschließlich huge.pdf Datei und später gelöscht, aber immer noch data.zip bleibt die gleiche Größe. Beim Entpacken konnte ich die Datei huge.pdf dort sehen.Unix zip-Befehl wird vorhandenes Archiv aktualisieren statt einen neuen

und ich bin in einer Anwendung dieses Shell-Befehl ausführt (NodeJS)

Antwort

1

Sie -FS Argument verwenden können, um FileSync:

$(which zip) -FSr ../data.zip . 

Alle Dateien nicht im aktuellen Verzeichnis und bereits in der zip wird daraus gelöscht und alle neuen Dateien werden hinzugefügt.

Von man zip:

-FS 
     --filesync 
       Synchronize the contents of an archive with the files on the OS. Normally when an archive is updated, new files are added and changed files are updated but files that no longer exist 
       on the OS are not deleted from the archive. This option enables a new mode that checks entries in the archive against the file system. If the file time and file size of the entry 
       matches that of the OS file, the entry is copied from the old archive instead of being read from the file system and compressed. If the OS file has changed, the entry is read and com‐ 
       pressed as usual. If the entry in the archive does not match a file on the OS, the entry is deleted. Enabling this option should create archives that are the same as new archives, 
       but since existing entries are copied instead of compressed, updating an existing archive with -FS can be much faster than creating a new archive. Also consider using -u for updating 
       an archive. 
+0

bitte Dokumentation Link – user2727195

+1

liefern Ich habe mit einem Link zu Zip-Handbuch aktualisiert –