Delete every other file from zip file.
How I can delete every alternate file from a zip file(1st,3rd,5th....) with command without unziping zip file.
I also want this operation on multiple zip files. Thanks. |
You can't.
|
I doubt if you can. And, doesn't serve much purpose. If you want to edit a zip file.
You could extract the files to temp, edit the files, then rezip. https://superuser.com/questions/6476...tly-extracting https://www.geeksforgeeks.org/zip-co...with-examples/ |
You can by writing a bash script.
1. Create a file with just the file names using the zipinfo utility. 2. Use a while loop to iterate through the list and delete the desired file using the zip -d option. There are many ways to expand the script to work on multiple zip files but not enough information has been provided. |
You can't do what was suggested in post #1 because there's no way of deleting part of an archive, so the zips would have the deleted files anyhow.
All explopde --> delete --> re-zip solutions are good, but more processor intensive. |
Something like this
zipinfo -1 q.zip|while read f;do read f;echo $f;done|zip -d -@ q.zip |
Just to make this absolutely clear:
Yes, you can delete from ZIP files without decompressing the entire archive. You can't do it with a TGZ archive, because the files are concatenated into a single lump of data before compression, but ZIP files do not work the same way. This means ZIP archives tend to have less compression, but provides the benefits of being able to view/extract an individual file without decompressing other files, as well as being able to add/update/remove files without recompressing the whole archive. Some archive formats (e.g. RAR) give you a choice of whether to use solid compression or not. |
Quote:
This smells like another homework problem. :p |
All times are GMT -5. The time now is 07:08 AM. |