Bash Index : Z - The 'Z' Bash commands : description, flags and examples

mail

zip

Usage

Package and compress (archive) files

Example

archive files

  • zip myArchive fileToZip1 fileToZip2
    .zip is automatically appended to the archive name, except if it already has a .
  • zip myArchive.zip fileToZip1 fileToZip2

list the contents of an archive (source)

  • unzip -l archive.zip
  • zipinfo -1 archive.zip
  • less archive.zip

extract multiple .zip files (sources : 1, 2)

unzip archive1.zip archive2.zip
Archive:  archive1.zip
caution: filename not matched:  archive2.zip
This happens because the command above is interpreted as extract archive2 from archive archive1, which doesn't exist.
To extract both archives :
  • unzip '*zip'
  • unzip archive1.zip && unzip archive2.zip
  • for zipFile in archive1.zip archive2.zip do; unzip "$zipFile"; done