我如何编辑文件没有解压缩存档,原因是我正在写自动化任务,我可以做解压缩,编辑文件和压缩,但它会很好,如果我可以在运行时做到这一点,这将节省时间来解压缩。
zip
手册页提供-u
选项来更新zip压缩文件。 你可以这样使用它:
zip -u bigzip.zip file/to/update1 file/to/update2 ...
这不会是瞬间的,但会快很多。 如果我创建一个示例200MB的zip文件:
mkdir source for (( f = 0; f < 200; f++ )); do head -c 1000000 /dev/random > source/${f} done zip -0r bigzip.zip source
然后解压缩,编辑一个文件,然后在我的机器上重新大约9s:
unzip bigzip.zip head -c 1000000 /dev/random > source/3 zip -0r bigzip.zip source
但是只需要大约3s就可以调用zip -u
。
mkdir source head -c1000000 /dev/random > source/3 zip -u bigzip.zip source/3