ZIP Files
- ZIP is a common archiving format, mainly on Windows, supported in Linux via
zipandunzip. - Default behavior: add files and compress them.
- Format :
zip [OPTIONS] [zipfile [file…]]
Create a ZIP archive:
zip archive.zip file1 file2 file3 # Create archive
zip -r archive.zip directory/ # Recursively add directory contents
-r→ include subdirectories- ZIP does not recurse by default, unlike tar.
List contents of a ZIP:
Extract files from a ZIP:
unzip archive.zip # Extract all files
unzip archive.zip path/to/file # Extract specific file
unzip archive.zip 'dir/*pattern*' # Extract files using wildcard
Tips:
- Extraction prompts if files already exist (
[y]es, [n]o, [A]ll, [N]one, [r]ename). - To avoid overwriting, extract into a new directory:
- ZIP also supports replacing files, setting compression levels, and encryption.
