Home Explore Blog CI



man-pages

3rd chunk of `zip.man`
0de6253a9e0033c6355f74d300f3675f3ae8a35a9afc19cf0000000100000fd7
         file1 file3

       then foo.zip will have:

               foo/file1 foo/file2 foo/file3

       where foo/file1 is replaced and foo/file3 is new.

       -@ file lists.   If  a  file list is specified as -@ [Not on MacOS], zip
       takes the list of input files from standard input instead  of  from  the
       command line.  For example,

              zip ‐@ foo

       will store the files listed one per line on stdin in foo.zip.

       Under  Unix,  this  option can be used to powerful effect in conjunction
       with the find (1) command.  For example, to archive  all  the  C  source
       files in the current directory and its subdirectories:

              find . ‐name "*.[ch]" ‐print | zip source ‐@

       (note  that  the pattern must be quoted to keep the shell from expanding
       it).

       Streaming input and output.  zip will also accept a single dash ("‐") as
       the zip file name, in which case it will write the zip file to  standard
       output, allowing the output to be piped to another program. For example:

              zip ‐r ‐ . | dd of=/dev/nrst0 obs=16k

       would  write  the zip output directly to a tape with the specified block
       size for the purpose of backing up the current directory.

       zip also accepts a single dash ("‐") as the name of a file  to  be  com‐
       pressed, in which case it will read the file from standard input, allow‐
       ing zip to take input from another program. For example:

              tar cf ‐ . | zip backup ‐

       would  compress the output of the tar command for the purpose of backing
       up the current directory. This  generally  produces  better  compression
       than  the  previous example using the ‐r option because zip can take ad‐
       vantage of redundancy between files. The backup can  be  restored  using
       the command

              unzip ‐p backup | tar xf ‐

       When no zip file name is given and stdout is not a terminal, zip acts as
       a filter, compressing standard input to standard output.  For example,

              tar cf ‐ . | zip | dd of=/dev/nrst0 obs=16k

       is equivalent to

              tar cf ‐ . | zip ‐ ‐ | dd of=/dev/nrst0 obs=16k

       zip  archives  created  in this manner can be extracted with the program
       funzip which is provided in the unzip package, or  by  gunzip  which  is
       provided  in  the  gzip package (but some gunzip may not support this if
       zip used the Zip64 extensions). For example:

              dd if=/dev/nrst0  ibs=16k | funzip | tar xvf ‐

       The stream can also be saved to a file and unzip used.

       If Zip64 support for large files and archives is enabled and zip is used
       as a filter, zip creates a Zip64 archive that requires a  PKZIP  4.5  or
       later  compatible unzip to read it.  This is to avoid ambiguities in the
       zip file structure as defined in the current zip standard  (PKWARE  App‐
       Note)  where  the  decision to use Zip64 needs to be made before data is
       written for the entry, but for a stream the size  of  the  data  is  not
       known  at that point.  If the data is known to be smaller than 4 GB, the
       option -fz- can be used to prevent use of Zip64, but zip will exit  with
       an  error  if Zip64 was in fact needed.  zip 3 and unzip 6 and later can
       read archives with Zip64 entries.  Also, zip removes  the  Zip64  exten‐
       sions if not needed when archive entries are copied (see the -U (--copy)
       option).

       When  directing the output to another file, note that all options should
       be before the redirection including ‐x.  For example:

              zip archive "*.h" "*.c" ‐x donotinclude.h orthis.h > tofile

       Zip files.  When changing an existing zip archive, zip will write a tem‐
       porary file with the new contents, and only replace the old one when the
       process of creating the new version has been completed without error.

       If the

Title: zip: File Lists, Streaming Input/Output, and Zip64 Support
Summary
This section details the use of file lists with the `zip` command, including examples of using `find` to archive files. It covers streaming input and output, demonstrating how to use `zip` as a filter to compress data from standard input to standard output, including examples using `tar` and `dd`. The section also addresses Zip64 support for large files and archives, discussing compatibility with different unzip versions and the use of the `-fz-` option. Finally, it mentions how zip handles changing existing archives and writing temporary files.