Edit file without unzipping archive
bash, linux, php-ziparchive
Solution
The `zip` man page provides a `-u` option to update a zip archive. You can use it like so:
zip -u bigzip.zip file/to/update1 file/to/update2 ...
It won't be instant, but it will be a lot faster. If I create a sample 200MB zip file:
mkdir source
for (( f = 0; f < 200; f++ )); do
head -c 1000000 /dev/random > source/${f}
done
zip -0r bigzip.zip source
then unzipping, editing one file, and rezipping takes about 9s on my machine:
unzip bigzip.zip
head -c 1000000 /dev/random > source/3
zip -0r bigzip.zip source
but it takes only about 3s to call `zip -u`.
mkdir source
head -c1000000 /dev/random > source/3
zip -u bigzip.zip source/3
Problem
How do i edit file without unzipping archive, reason is i am writing automation task, I can do unzip, edit file and zip it, But it would be good if i can do it in runtime so it will save time to unzip/zip.