home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


zip [options ] zipfile [files ]

Archive files in InfoZIP format. These files can be retrieved using unzip . The files are compressed as they are added to the archive. Compression ratios of 2:1 to 3:1 are common for text files. zip may also replace files in an existing archive. With no arguments, display the help information. See also zipinfo and unzip .

Default options may be placed in the ZIPOPT environment variable, with the exceptions of -i and -x . Multiple options may be included in ZIPOPT .

While zip is not distributed with SVR4 or Solaris, source code is readily available from http://www.cdrom.com/pub/infozip .

There are a number of important notes in the unzip entry. Go there for more information.


-b path

Use path as the location to store the temporary ZIP archive while updating an existing one. When done, copy the temporary archive over the new one. Useful primarily when there is not enough disk space on the filesystem containing the original archive.


Add one-line comments for each file. zip first performs any file operations and then prompts you for a comment describing each file.


Delete entries from a ZIP archive. Filenames to be deleted must be entered in uppercase if the archive was created by PKZIP on an MS-DOS system.


Don't create entries in the archive for directories. Usually entries are created, so that attributes for directories may be restored upon extraction.


Encrypt the archive. zip prompts on the terminal for a password and prompts twice, to avoid typing errors. If standard error is not a terminal, zip exits with an error.


Freshen (replace) an existing entry in the ZIP archive if the file has a more recent modification time than the one in the archive. This doesn't add files that are not already in the archive: use -u for that. Run this command from the same directory where the ZIP archive was created, since the archive stores relative path names.

-F , -FF

Fix the ZIP archive. This option should be used with care; make a backup copy of the archive first. The -FF version does not trust the compressed sizes in the archive, and instead scans it for special "signatures" that identify the boundaries of different archive members. See the manpage for more information.


Grow the archive (append files to it).


Display the zip help information.

-i files

Include only the specified files , typically specified as a quoted shell wildcard-style pattern.


"Junk" the path; i.e., store just the name of the saved file, not any directory names. The default is to store complete paths, although paths are always relative.


Strip any prepended data (e.g., an SFX stub, for self-extracting executables) from the archive.


Create an archive that (attempts to) conform to the conventions used under MS-DOS. This makes it easier for PKUNZIP to extract the archive.


For text files only, translate the Unix newline into a CR-LF pair. Primarily for archives extracted under MS-DOS.


For text files only, translate the MS-DOS CR-LF into a Unix newline.


Display the zip license.


"Move" the files into the ZIP archive. This actually deletes the original files and/or directories after the archive has been created successfully. This is somewhat dangerous; use -T in conjunction with this option.

-n suffixlist

Do not compress files with suffixes in suffixlist . Useful for sound or image files that often have their own, specialized compression method.


Set the modified time of the ZIP archive to be that of the youngest file (most recently modified) in the archive.


Quiet mode. Don't print informational messages and comment prompts. Most useful in shell scripts.


Recursively archive all files and subdirectories of the named files . The -i option is also useful in combination with this one.

-t mmddyy

Ignore files modified prior to the date given by mmddyy .


Test the new ZIP archive's integrity. If the test fails, an existing ZIP archive is not changed, and with -m , no files are removed.


Update existing entries in the ZIP archive if the named files have modification dates that are newer than those in the archive. Similar to -f , except that this option adds files to the archive if they aren't already there.


As the only argument, print help and version information, a pointer to the home and distribution Internet sites, and information about how zip was compiled. When used with other options, cause those options to print progress information and provide other diagnostic information.

-x files

Exclude the specified files , typically specified as a quoted shell wildcard-style pattern.


Do not save extra file attributes (extended attributes on OS/2, user ID/group ID, and file times on Unix).


Preserve symbolic links in the ZIP archive, instead of archiving the file the link points to.


Prompt for a (possibly multiline) comment describing the entire ZIP archive. End the comment with line containing just a period, or EOF .

- n

Specify compression speed: n is a digit between 0 and 9. 0 indicates no compression, 1 indicates fast but minimal compression, 9 indicates slowest but maximal compression. Default is -6 .


Read standard input for names of files to be archived. Filenames containing spaces must be quoted using single quotes.


Archive the current directory into source.zip , including only C source files:

zip source -i '*.[ch]'

Archive the current directory into source.zip , excluding the object files:

zip source -x '*.o'

Archive files in the current directory into source.zip , but don't compress .tiff and .snd files:

zip source -z '.tiff:.snd' *

Recursively archive the entire directory tree into one archive:

zip -r /tmp/dist.zip .

Previous: Reference: zcat UNIX in a Nutshell: System V Edition Next: Reference: zipinfo
Reference: zcat Book Index Reference: zipinfo

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System