Sometimes when we’re working with zip files, we need to remove some files inside it to doesn’t override another files during extraction. Linux has a special app to this, we’re talking about zip.
Debian based distros like Ubuntu, Mint, etc., already have this program installed, CentOS for instance doesn’t have installed, so, to install it you will do this:
[bash]sudo yum install zip[/bash]
To those distros, the way to use zip app it’s the same.
Deleting specific files inside a zip file
If you want to delete one or more specific files, you can do this:
[bash]zip –delete your-zip.zip “file1.txt” “file2.txt” “directory/sub-folder/file2.txt”[/bash]
Like /bin/rm command, this app also can receive N parameters on –delete arg.
If you want to delete directories inside a zip file, it is the almost same way, but you will add “/*” at the end of string arg. Bellow you have an example of it:
[bash]zip –delete your-zip.zip “directory1/*” “directory2/*” “directory3/sub-folder/*”[/bash]
Pay attention to the last parameter, “directory3/sub-folder/*”, in this case, the folder “sub-folder” will be deleted from “directory3” folder.
Be happy : )