Compress
zip <output> <target1> <target2> ...
zip example.zip example1.txt example2.txt
# -r: recursive (zip folder)
zip -r example.zip ./example
Symbolic Links
We can store symbolic links in a zip file.
Decompress
List Files without Decompressings
To list files in a zip file without extracting, use -l
flag.
Unzip with Python
Also we can decompress an archived file using Python script.
import zipfile
filename = "./sample.zip"
extdir = "./"
password = "password123"
with zipfile.ZipFile(filename, 'r') as zp:
try:
zp.extractall(path=extdir, pwd=password.encode('utf-8'))
except RuntimeError as e:
print(e)