linux how to add a file to a specific folder within a zip file
To elaborate on @Ignacio Vazquez-Abrams answer from a year ago, you can use a lower level library, such as the one that comes with Python:
#!/bin/bashpython -c 'import zipfile as zf, sysz=zf.ZipFile(sys.argv[1], "a")z.write(sys.argv[2], sys.argv[3])z.close()' myfile.zip source/dir/file.txt dir/in/zip/file.txt
This will open myfile.zip
and add source/dir/file.txt
from the file system as dir/in/zip/file.txt
in the zip file.