Linux zip command
The zip program is used to package and compress files.
zip is a compression and file packaging utility for Unix, VMS, MSDOS, OS/2, Windows 9x/NT/XP, Minix, Atari, Macintosh, Amiga, and Acorn RISC OS. It is analogous to a combination of the Unix commands tar and compress, and it is compatible with PKZIP.
A separate companion program, unzip, unpacks and uncompresses zip archives. The zip and unzip programs can work with archives produced by PKZIP (supporting most PKZIP features up to PKZIP version 4.6), and PKZIP and PKUNZIP can work with archives produced by zip (with some exceptions).
zip supports macOS X, and on that OS, most Unix features are the same.
zip is useful for packaging a set of files for distribution, for archiving files, and for saving disk space by temporarily compressing unused files or directories.
The zip program puts one or more compressed files into a single zip archive, along with information about the files (name, path, date, time of last modification, protection, and check information to verify file integrity). An entire directory structure can be packed into a zip archive with a single command. Compression ratios of 2:1 to 3:1 are common for text files. zip has one compression method (deflation) and can also store files without compression. (If bzip2 support is added, zip can also compress using bzip2 compression, but such entries require a reasonably modern unzip to decompress. When bzip2 compression is selected, it replaces deflation as the default method.) zip automatically chooses the better of the two (deflation or store or, if bzip2 is selected, bzip2 or store) for each file to be compressed.
The basic command format is:
. where archive is a new or existing zip archive and inpath is a directory or file path optionally including wildcards. When given the name of an existing zip archive, zip will replace identically named entries in the zip archive (matching the relative names as stored in the archive) or add entries for new names. For example, if foo.zip exists and contains foo/file1 and foo/file2, and the directory foo contains the files foo/file1 and foo/file3, then:
. will replace foo/file1 in foo.zip and add foo/file3 to foo.zip. After this, foo.zip contains foo/file1, foo/file2, and foo/file3, with foo/file2 unchanged from before.
So if before the zip command is executed foo.zip has:
and directory foo has:
then foo.zip will have:
. where foo/file1 is replaced and foo/file3 is new.
If a file list is specified as [email protected], zip takes the list of input files from standard input instead of from the command line. For example,
. will store the files listed, one per line on standard input, in the archive foo.zip.
Under Unix, this option can be used to powerful effect in conjunction with the find command. For example, to archive all the C source files in the current directory and its subdirectories:
(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:
. 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 compressed, in which case it will read the file from standard input, allowing zip to take input from another program. For example:
. 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 advantage of redundancy between files. The backup can be restored using the command:
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,
zip archives created in this manner can be extracted with the program funzip that is provided in the unzip package, or by gunzip that is provided in the gzip package (but some installations of gunzip may not support this if zip used the Zip64 extensions). For example:
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 the file. To avoid amgibuities in the zip file structure as defined in the current zip standard (PKWARE AppNote) 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 extensions 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:
Please note that [email protected] lists do not work on macOS.
When changing an existing zip archive, zip will write a temporary 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 name of the zip archive does not contain an extension, the extension .zip is added. If the name already contains an extension other than .zip, the existing extension is kept unchanged. However, split archives (archives split over multiple files) require the .zip extension on the last split.
Scanning And Reading Files
When zip starts, it scans for files to process (if needed). If this scan takes longer than about 5 seconds, zip displays a “Scanning files” message and start displaying progress dots every 2 seconds or every so many entries processed, whichever takes longer. If there is more than 2 seconds between dots it could indicate that finding each file is taking time and could mean a slow network connection for example. (Actually the initial file scan is a two-step process where the directory scan is followed by a sort and these two steps are separated with a space in the dots. If updating an existing archive, a space also appears between the existing file scan and the new file scan.) The scanning files dots are not controlled by the -ds dot size option, but the dots are turned off by the -q quiet option. The -sf show files option can be used to scan for files and get the list of files scanned without actually processing them.
If zip is not able to read a file, it issues a warning but continues. See the -MM option below for more on how zip handles patterns that are not matched and files that are not readable. If some files were skipped, a warning is issued at the end of the zip operation noting how many files were read and how many skipped.
zip now supports two distinct types of command modes, external and internal. The external modes (add, update, and freshen) read files from the file system (as well as from an existing archive) while the internal modes (delete and copy) operate exclusively on entries in an existing archive.
|add||Update existing entries and add new files and create it if the archive does not exist. This option is the default mode.|
|update (-u)||Update existing entries if newer on the file system and add new files. If the archive does not exist issue warning then create a new archive.|
|freshen (-f)||Update existing entries of an archive if newer on the file system. Does not add new files to the archive.|
|delete (-d)||Select entries in an existing archive and delete them.|
|copy (-U)||Select entries in an existing archive and copy them to a new archive. This new mode is similar to update but command line patterns select entries in the existing archive rather than files from the file system and it uses the –out option to write the resulting archive to a new file rather than update the existing archive, leaving the original archive unchanged.|
The new File Sync option (-FS) is also considered a new mode, though it is similar to update. This mode synchronizes the archive with the files on the OS, only replacing files in the archive if the file time or size of the OS file is different, adding new files, and deleting entries from the archive where there is no matching file. As this mode can delete entries from the archive, consider making a backup copy of the archive.
Also see -DF for creating difference archives.
zip version 3.0 and later can create split archives. A split archive is a standard zip archive split over multiple files. (Note that split archives are not just archives split in to pieces, as the offsets of entries are now based on the start of each split. Concatenating the pieces together will invalidate these offsets, but unzip can usually deal with it. zip will usually refuse to process such a spliced archive unless the -FF fix option is used to fix the offsets.)
One use of split archives is storing a large archive on multiple removable media. For a split archive with 20 split files the files are typically named (replace ARCHIVE with the name of your archive) ARCHIVE.z01, ARCHIVE.z02, . ARCHIVE.z19, ARCHIVE.zip. Note that the last file is the .zip file. In contrast, spanned archives are the original multi-disk archive generally requiring floppy disks and using volume labels to store disk numbers. zip supports split archives but not spanned archives, though a procedure exists for converting split archives of the right size to spanned archives. The reverse is also true, where each file of a spanned archive can be copied to files with the above names to create a split archive.
Use -s to set the split size and create a split archive. The size is given as a number followed optionally by one of k (kB), m (MB), g (GB), or t (TB) (the default is m). The -sp option can be used to pause zip between splits to allow changing removable media, for example, but read the descriptions and warnings for both -s and -sp below.
Though zip does not update split archives, zip provides the new option -O (–output-file or –out) to allow split archives to be updated and saved in a new archive. For example,
. reads archive inarchive.zip, even if split, adds the files foo.c and bar.c, and writes the resulting archive to outarchive.zip. If inarchive.zip is split then outarchive.zip defaults to the same split size. Be aware that if outarchive.zip and any split files that are created with it already exist, these are always overwritten as needed without warning. This may be changed in the future.
Though the zip standard requires storing paths in an archive using a specific character set, in practice zips have stored paths in archives in whatever the local character set is. Problems can occur when an archive is created or updated on a system using one character set and then extracted on another system using a different character set. When compiled with Unicode support enabled on platforms that support wide characters, zip now stores, in addition to the standard local path for backward compatibility, the UTF-8 translation of the path. This provides a common universal character set for storing paths that allows these paths to be fully extracted on other systems that support Unicode and to match as close as possible on systems that don’t.
On Win32 systems where paths are internally stored as Unicode but represented in the local character set, it’s possible that some paths will be skipped during a local character set directory scan. zip with Unicode support now can read and store these paths. Note that Win 9x systems and FAT file systems don’t fully support Unicode.
Be aware that console windows on Win32 and Unix, for example, sometimes don’t accurately show all characters due to how each operating system switches in character sets for display. However, directory navigation tools should show the correct paths if the needed fonts are loaded.
Command Line Format
This version of zip has updated command line processing and support for long options.
Short options take the form:
. where s is a one or two character short option. A short option that takes a value is last in an argument and anything after it is taken as the value. If the option can be negated and “–” immediately follows the option, the option is negated. Short options can also be given as separate arguments
Short options in general take values either as part of the same argument or as the following argument. An optional = is also supported. So -ttmmddyyyy, -tt=mmddyyyy, and -tt mmddyyyy all work. The -x and -i options accept lists of values and use a slightly different format described below. See the -x and -i options.
Long options take the form
where the option starts with —, has a multicharacter name, can include a trailing dash to negate the option (if the option supports it), and can have a value (option argument) specified by preceding it with = (no spaces). Values can also follow the argument. So –before-date=mmddyyyy and –before-date mmddyyyy both work.
Long option names can be shortened to the shortest unique abbreviation. See the option descriptions below for which support long options. To avoid confusion, avoid abbreviating a negatable option with an embedded dash (“–“) at the dash if you plan to negate it (the parser would consider a trailing dash, such as for the option –some-option using –some- as the option, as part of the name rather than a negating dash). This may be changed to force the last dash in –some- to be negating in the future.
|-a, –ascii||On systems using EBCDIC, this option translates files to ASCII format.|
|-A, –adjust-sfx||Adjust self-extracting executable archive. A self-extracting executable archive is created by prepending the “SFX” stub to an existing archive. The -A option tells zip to adjust the entry offsets stored in the archive to take into account this “preamble” data.|
|-AC, –archive-clear||This option is a Windows-only option. Once archive is created (and tested if -T is used, which is recommended), clear the archive bits of files processed. Once the bits are cleared they are cleared permanently. You may want to use the -sf (show files) option to store the list of files processed in case the archive operation must be repeated. Also consider using the -MM (must match) option. Be sure to check out -DF as a possibly better way to do incremental backups.|
|-AS, –archive-set||This option is a Windows-only option which only includes files that have the archive bit set. Directories are not stored when -AS is used, though by default the paths of entries, including directories, are stored as usual and can be used by most unzips to recreate directories.|
The archive bit is set by the operating system when a file is modified and, if used with -AC, -AS can provide an incremental backup capability. However, other applications can modify the archive bit and it may not be a reliable indicator of which files have changed since the last archive operation. Alternative ways to create incremental backups are using -t to use file dates, though this won’t catch old files copied to directories being archived, and -DF to create a differential archive.
. will put the temporary zip archive in the directory /tmp, copying over stuff.zip to the current directory when done. This option is useful when updating an existing archive and the file system containing this old archive does not have enough space to hold both old and new archives at the same time. It may also be useful when streaming in some cases to avoid the need for data descriptors. Note that using this option may require zip take additional time to copy the archive file when done to the destination file system.
. will remove the entry foo/tom/junk, all of the files that start with foo/harry/, and all of the files that end with .o (in any path). Note that shell pathname expansion has been inhibited with backslashes, so that zip can see the asterisks, enabling zip to match on the contents of the zip archive instead of the contents of the current directory. (The backslashes are not used on MSDOS-based platforms.) Can also use quotes to escape the asterisks, as in
Not escaping the asterisks on a system where the shell expands wildcards could result in the asterisks being converted to a list of files in the current directory and that list used to delete entries from the archive.
Under MSDOS, -d is case sensitive when it matches names in the zip archive. This requires that file names be entered in upper case if they were zipped by PKZIP on an MSDOS system. See the option -ic to ignore case in the archive.
. will turn off most output except dots every 10 MB.
The -v option also displays dots and now defaults to 10 MB also. This rate is also controlled by this option. A size of turns dots off.
This option does not control the dots from the “Scanning files” message as zip scans for input files. The dot size for that is fixed at 2 seconds or a fixed number of entries, whichever is longer.
(The variable ZIPOPT can be used for any option, including -i and -x using a new option format detailed below, and can include several options.) The option -D is a shorthand for -x “*/” but the latter previously could not be set as default in the ZIPOPT environment variable as the contents of ZIPOPT gets inserted near the beginning of the command line and the file list had to end at the end of the line.
This version of zip does allow -x and -i options in ZIPOPT if the form
. is used, where the @ (an argument that is just @) terminates the list.
For example, if the existing archive was created using
from the bar directory, then the command
. also from the bar directory creates the archive foonew with just the files not in foofull and the files where the size or file time of the files do not match those in foofull.
Note that the timezone environment variable TZ should be set according to the local timezone for this option to work correctly. A change in timezone since the original archive was created could result in no times matching and all files being included.
A possible approach to backing up a directory might be to create a normal archive of the contents of the directory as a full backup, then use this option to create incremental backups.
This command should be run from the same directory from which the original zip command was run, since paths stored in zip archives are always relative.
Note that the timezone environment variable TZ should be set according to the local timezone for the -f, -u and -o options to work correctly.
The reasons behind this are somewhat subtle but have to do with the differences between the Unix-format file times (always in GMT) and most of the other operating systems (always local time) and the necessity to compare the two. A typical TZ value is “MET-1MEST” (Middle European time with automatic adjustment for “summertime” or Daylight Savings Time).
The format is TTThhDDD, where TTT is the time zone such as PST, hh is the difference between GMT and local time such as -1 above, and DDD is the time zone when daylight savings time is in effect. Leave off the DDD if there is no daylight savings time. For the US Eastern time zone: EST5EDT.
When doubled as in -FF, the archive is scanned from the beginning and zip scans for special signatures to identify the limits between the archive members. The single -F is more reliable if the archive is not too much damaged, so try this option first.
If the archive is too damaged or the end has been truncated, you must use -FF. This option is a change from zip 2.32, where the -F option can read a truncated archive. The -F option now more reliably fixes archives with minor damage and the -FF option is needed to fix archives where -F might have been sufficient before.
Neither option will recover archives that have been incorrectly transferred in ascii mode instead of binary. After the repair, the -t option of unzip may show that some files have a bad CRC. Such files cannot be recovered; you can remove them from the archive using the -d option of zip.
Note that -FF may have trouble fixing archives that include an embedded zip archive that was stored (without compression) in the archive and, depending on the damage, it may find the entries in the embedded archive rather than the archive itself. Try -F first as it does not have this problem.
The format of the fix commands have changed. For example, to fix the damaged archive foo.zip,
. tries to read the entries normally, copying good entries to the new archive foofix.zip. If this doesn’t work, as when the archive is truncated, or if some entries you know are in the archive are missed, then try
. and compare the resulting archive to the archive created by -F. The -FF option may create an inconsistent archive. Depending on what is damaged, you can then use the -F option to fix that archive.
A split archive with missing split files can be fixed using -F if you have the last split of the archive (the .zip file). If this file is missing, you must use -FF to fix the archive, which will prompt you for the splits you have.
Currently the fix options can’t recover entries that have a bad checksum or are otherwise damaged.
For this option to work, the archive should be updated from the same directory it was created in so the relative paths match. If few files are being copied from the old archive, it may be faster to create a new archive instead.
Note that the timezone environment variable TZ should be set according to the local timezone for this option to work correctly. A change in timezone since the original archive was created could result in no times matching and recompression of all files.
This option deletes files from the archive. If you need to preserve the original archive, make a copy of the archive first or use the –out option to output the updated archive to a new file. Even though it may be slower, creating a new archive with a new archive name is safer, avoids mismatches between archive and OS paths, and is preferred.
. which will include only the files that end in .c in the current directory and its subdirectories. (Note for PKZIP users: the equivalent command is
PKZIP does not allow recursion in directories other than the current one.) The backslash avoids the shell file name substitution, so that the name matching is performed by zip at all directory levels. [This option is for Unix and other systems where “\” escapes the next character.] So to include dir, a directory directly under the current directory, use:
. to match paths such as dir/a and dir/b/file.c. Note that currently the trailing / is needed for directories (as in:
. to include directory dir).
The long option form of the first example is:
. and does the same thing as the short option form.
Though the command syntax used to require -i at the end of the command line, this version actually allows -i (or –include) anywhere. The list of files terminates at the next argument starting with –, the end of the command line, or the list terminator @ (an argument that is just @). So the above can be given as:
. for example. There must be a space between the option and the first file of a list. For just one file you can use the single value form:
(no space between option and value) or:
. as additional examples. The single value forms are not recommended because they can be confusing and, in particular, the -ifile format can cause problems if the first letter of file combines with i to form a two-letter option starting with i. Use -sc to see how your command line will be parsed.
. which will only include the files in the current directory and its subdirectories that match the patterns in the file include.lst.
Files to -i and -x are patterns matching internal archive paths. See -R for more on patterns.
For example, if you have SparkFS loaded, zipping a Spark archive will result in a zipfile containing a directory (and its content) while using the ‘I‘ option will result in a zipfile containing a Spark archive. Obviously this second case will also be obtained (without the ‘I‘ option) if SparkFS isn’t loaded.
This option is useful when a known list of files is to be zipped so any missing or unreadable files will result in an error. It is less useful when used with wildcards, but zip will still exit with an error if any input pattern doesn’t match at least one file and if any matched files are unreadable. If you want to create the archive anyway and only need to know if files were skipped, don’t use -MM and just check the return code. Also -lf could be useful.
will copy everything from foo into foo.zip, but will store any files that end in .Z, .zip, .tiff, .gif, or .snd without trying to compress them (image and sound files often have their own specialized compression methods). By default, zip does not compress files with extensions in the list .Z:.zip:.zoo:.arc:.lzh:.arj. Such files are stored directly in the output archive. The environment variable ZIPOPT can be used to change the default options. For example under Unix with csh:
To attempt compression on all files, use:
The maximum compression option -9 also attempts compression on all files regardless of extension.
On Acorn RISC OS systems the suffixes are actually filetypes (3 hex digit format). By default, zip does not compress files with filetypes in the list DDC:D96:68E (i.e. Archives, CFS files and PackDir files).
. will change the last modified time of foo.zip to the latest time of the entries in foo.zip.
This option can be used to create updated split archives. It can also be used with -U to copy entries from an existing archive to a new archive.
Another use is converting zip files from one split size to another. For instance, to convert an archive with 700 MB CD splits to one with 2 GB DVD splits, can use:
. which uses copy mode. See -U below. Also:
. will convert a split archive to a single-file archive.
Copy mode will convert stream entries (using data descriptors and which should be compatible with most unzips) to normal entries (which should be compatible with all unzips), except if standard encryption was used. For archives with encrypted entries, zipcloak will decrypt the entries and convert them to normal entries.
In this case, all the files and directories in foo are saved in an archive named foo.zip, including files with names starting with “.“, since the recursion does not use the shell’s file-name substitution mechanism. If you want to include only a specific subset of the files in directory foo and its subdirectories, use the -i option to specify the pattern of files to be included. You should not use -r with the name “.*“, since that matches “..” which will attempt to zip up the parent directory (probably not what was intended).
Multiple source directories are allowed:
. which first zips up foo1 and then foo2, going down each directory.
Note that while wildcards to -r are typically resolved while recursing down directories in the file system, any -R, -x, and -i wildcards are applied to internal archive pathnames once the directories are scanned. To have wildcards apply to files in subdirectories when recursing on Unix and similar systems where the shell does wildcard substitution, either escape all wildcards or put all arguments with wildcards in quotes. This lets zip see the wildcards and match files in subdirectories using them as it recurses.
In this case, all the files matching *.c in the tree starting at the current directory are stored into a zip archive named foo.zip. Note that *.c will match file.c, a/file.c and a/b/.c. More than one pattern can be listed as separate arguments. Note for PKZIP users: the equivalent command is
Patterns are relative file paths as they appear in the archive, or will after zipping, and can have optional wildcards in them. For example, given the current directory is foo and under it are directories foo1 and foo2 and in foo1 is the file bar.c,
. will zip up foo, foo/foo1, foo/foo1/bar.c, and foo/foo2.
. will zip up foo/foo1/bar.c. See the note for -r on escaping wildcards.
Split archives are stored in numbered files. For example, if the output archive is named archive and three splits are required, the resulting archive will be in the three files archive.z01, archive.z02, and archive.zip. Do not change the numbering of these files or the archive will not be readable as these are used to determine the order the splits are read.
Split size is a number optionally followed by a multiplier. Currently the number must be an integer. The multiplier can currently be one of k (kilobytes), m (megabytes), g (gigabytes), or t (terabytes). As 64 k is the minimum split size, numbers without multipliers default to megabytes. For example, to create a split archive called foo with the contents of the bar directory with splits of 670 MB that might be useful for burning on CDs, the command:
Currently the old splits of a split archive are not excluded from a new archive, but they can be specifically excluded. If possible, keep the input and output archives out of the path being zipped when creating split archives.
Using -s without -sp as above creates all the splits where foo is being written, in this case the current directory. This split mode updates the splits as the archive is being created, requiring all splits to remain writable, but creates split archives that are readable by any unzip that supports split archives. See -sp below for enabling split pause mode that allows splits to be written directly to removable media.
The option -sv can be used to enable verbose splitting and provide details of how the splitting is being done. The -sb option can be used to ring the bell when zip pauses for the next split destination.
Split archives cannot be updated, but see the -O (–out) option for how a split archive can be updated as it is copied to a new archive. A split archive can also be converted into a single-file archive using a split size of 0 or negating the -s option:
Also see -U (–copy) for more on using copy mode.
Though this split mode allows writing splits directly to removable media, it uses stream archive format that may not be readable by some unzips. Before relying on splits created with -sp, test a split archive with the unzip you will be using.
To convert a stream split archive (created with -sp) to a standard archive see the –out option.
. will add all the files in foo and its subdirectories that were last modified on or after 7 December 1991, to the zip archive infamy.zip.
. will add all the files in foo and its subdirectories that were last modified before 30 November 1995, to the zip archive infamy.zip.
In cmd, <> is replaced by the name of the temporary archive, otherwise the name of the archive is appended to the end of the command. The return code is checked for success (0 on Unix).
. will add any new files in the current directory, and update any files which have been modified since the zip archive stuff.zip was last created/modified (note that zip will not try to pack stuff.zip into itself when you do this).
Note that the -u option with no input file arguments acts like the -f (freshen) option.
. copies entries with names ending in .c from inarchive to outarchive. The wildcard must be escaped on some systems to prevent the shell from substituting names of files from the file system which may have no relevance to the entries in the archive.
If no input files appear on the command line and –out is used, copy mode is assumed:
This option is useful for changing split size, for instance. Encrypting and decrypting entries is not yet supported using copy mode. Use zipcloak for that.
This option can be used to determine what zip should do with this path if there is a mismatch between the stored standard path and the stored UTF-8 path (which can happen if the standard path was updated). In all cases, if there is a mismatch it is assumed that the standard path is more current and zip uses that. Values for v are
|q||quit if paths do not match|
|w||warn, continue with standard path|
|i||ignore, continue with standard path|
|n||no Unicode, do not use Unicode paths|
The default is to warn and continue.
Characters that are not valid in the current character set are escaped as #Uxxxx and #Lxxxxxx, where x is an ASCII character for a hex digit. The first is used if a 16-bit character number is sufficient to represent the Unicode character and the second if the character needs more than 16 bits to represent it’s Unicode character code. Setting -UN to
. forces zip to escape all characters that are not printable 7-bit ASCII.
Normally zip stores UTF-8 directly in the standard path field on systems where UTF-8 is the current character set and stores the UTF-8 in the new extra fields otherwise. The option
. forces zip to store UTF-8 as native in the archive. Note that storing UTF-8 directly is the default on Unix systems that support it. This option could be useful on Windows systems where the escaped path is too large to be a valid path and the UTF-8 version of the path is smaller, but native UTF-8 is not backward compatible on Windows systems.
Normally, when applied to real operations, this option enables the display of a progress indicator during compression (see -dd for more on dots) and requests verbose diagnostic info about zipfile structure oddities.
However, when -v is the only command line argument a diagnostic screen is printed instead. This should now work even if stdout is redirected to a file, allowing easy saving of the information for sending with bug reports to Info-ZIP. The version screen provides the help screen header with program name, version, and release date, some pointers to the Info-ZIP home and distribution sites, and shows information about the target environment (compiler type and version, OS version, compilation date and the enabled optional features used to create the zip executable).
an input pattern such as
Normally would match both paths, the * matching dir/file1.c and file2.c. Note that in the first case a directory boundary (/) was crossed in the match. With -ws no directory bounds will be included in the match, making wildcards local to a specific directory level. So, with -ws enabled, only the second path would be matched.
When using -ws, use ** to match across directory boundaries as * does normally.
. which will include the contents of foo in foo.zip while excluding all the files that end in .o. The backslash avoids the shell file name substitution, so that the name matching is performed by zip at all directory levels.
. which will include the contents of foo in foo.zip while excluding all the files that match the patterns in the file exclude.lst.
The long option forms of the above are
Multiple patterns can be specified, as in:
If there is no space between -x and the pattern, just one value is assumed (no list):
See -i for more on include and exclude.
Negating this option, -X-, includes all the default extra fields, but also copies over any unrecognized extra fields.
|store||Setting the compression method to store forces zip to store entries with no compression. This method is generally faster than compressing entries, but results in no space savings. This method is the same as using -0 (compression level zero).|
|deflate||This method is the default method for zip. If zip determines that storing is better than deflation, the entry will be stored instead.|
|bzip2||If bzip2 support is compiled in, this compression method also becomes available. Only some modern unzips currently support the bzip2 compression method, so test the unzip you will be using before relying on archives using this method (compression method 12).|
For example, to add bar.c to archive foo using bzip2 compression:
The compression method can be abbreviated:
Though still being worked, the intention is this setting will control compression speed for all compression methods. Currently only deflation is controlled.
|ZIPOPT||Contains default options that will be used when running zip. The contents of this environment variable will get added to the command line just after the zip command.|
|ZIP||An alias for ZIPOPT, except on RISC OS and VMS.|
On Risc and VMS, there are additional special environment variables; consult your documentation for details.
Creates the archive stuff.zip (assuming it does not exist) and puts all the files in the current directory in it, in compressed form (the .zip suffix is added automatically, unless the archive name contains a dot already; this allows the explicit specification of other suffixes).
The same as the above command, but also includes files beginning with a dot (except for the special directory names “.” and “..“.
Zips the entire subdirectory foo into an archive, foo.zip, and records the name of the directory with each file.
Same as the above command, but unlike -r, the -j option will not record the name of the directory, just the names of the files themselves.
Creates a split archive of the directory foo with splits no bigger than 2 GB each. If foo contained 5 GB of contents and the contents were stored in the split archive without compression (to make this example simple), this would create three splits, split.z01 at 2 GB, split.z02 at 2 GB, and split.zip at a little over 1 GB.
compress — Compress a file or files.
tar — Create, modify, list the contents of, and extract files from tar archives.
unzip — List, test and extract compressed files in a zip archive.
gzip, gunzip, zcat — Create, modify, list the contents of, and extract files from GNU zip archives.
zipinfo — Display technical information about a zip file.