命令行大全

zip

舞夕之 发表于 2020-07-10 13:46浏览次数:

Zip程序用于打包和压缩文件。

查看英文版

目录:

1 zip 运行系统环境

2 zip 描述

3 zip 语法

4 zip 示例

zip 运行系统环境

Windows 95

Windows 98

Windows xp

Windows NT

unix

zip 描述

一个单独的伴随程序unzip,解压缩和解压缩zip档案。该压缩和解压程序可以与PKZIP生产档案(支持大多数PKZIP可提供高达PKZIP版本4.6)工作,PKZIP和PKUNZIP可以通过产生的档案工作拉链(有一些例外)。

zip支持macO X,在该O上,大多数Unix功能都是相同的。

用法

zip对于打包一组文件以进行分发,归档文件以及通过临时压缩未使用的文件或目录来节省磁盘空间很有用。

该压缩程序将一个或多个文件压缩成一个单一的zip压缩文件,并提供有关文件(名称,路径,日期,最后一次修改,保护和检查信息的时间来验证文件的信息一起完整性)。可以使用单个命令将整个目录结构打包到zip归档文件中。文本文件的压缩率通常为2:1到3:1。zip有一种压缩方法(deflation),并且还可以存储文件而无需压缩。(如果添加了bzip2支持,则zip也可以使用bzip2压缩进行压缩,但是此类条目需要相当现代的解压缩解压缩。当bzip2的被选择的压缩,它取代通缩作为缺省方法。)ZIP自动选择两个(的更好放气或商店,或如果bzip2的被选择,bzip2的或商店),用于每个文件被压缩。

命令格式

基本命令格式为:

zip options archive inpath inpath ...

其中archive是一个新的或现有的zip归档文件,而inpath是一个目录或文件路径,可以选择包含通配符。当给定现有zip归档文件的名称时,zip将替换zip归档文件中名称相同的条目(与存储在归档文件中的相对名称匹配)或添加新名称的条目。例如,如果foo.zip存在并且包含foo / file1和foo / file2,并且目录foo包含文件foo / file1和foo / file3,则:

zip -r foo.zip foo

或更简单的:

zip -r foo foo

将取代富/文件1在foo.zip并添加富/文件3至foo.zip。此后,foo.zip包含foo / file1,foo / file2和foo / file3,而foo / file2则从前保持不变。

因此,如果在执行zip命令之前foo.zip具有:

foo / file1  foo / file2

目录foo具有:

file1 
file3

那么foo.zip将具有:

foo / file1  foo / file2  foo / file3

其中foo / file1被替换而foo / file3是新的。

档案清单

如果文件列表指定为-@,则zip从标准输入而不是从命令行获取输入文件的列表。例如,

zip-@ foo

..将列出的文件(在标准输入中每行一个存储)存储在档案foo.zip中。

在Unix下,此选项可与find命令结合使用以产生强大的效果。例如,要将所有C&nbp;源文件归档在当前目录及其子目录中:

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

请注意,必须引用该模式以防止shell扩展它

流输入和输出。zip也将接受一个短划线作为zip文件名,在这种情况下,它将zip文件写入标准输出,从而允许将输出通过管道传输到另一个程序。例如:

zip -r-。| dd of = / dev / nrt0 ob = 16k

将zip输出直接写到具有指定块大小的磁带上,以备份当前目录。

zip还接受一个短划线,作为要压缩的文件的名称,在这种情况下,它将从标准输入读取文件,从而使zip可以从另一个程序获取输入。例如:

tar cf-。| zip backup -

将压缩tar命令的输出,以备份当前目录。与使用-r选项的上一个示例相比,这通常会产生更好的压缩,因为zip可以利用文件之间的冗余。可以使用以下命令恢复备份:

unzip -p backup | tar xf -

如果未提供zip文件名并且tdout不是终端,则zip充当过滤器,将标准输入压缩为标准输出。例如,

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

相当于

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

可以使用unzip软件包中提供的funzip程序或gzip软件包中提供的gunzip提取以这种方式创建的zip归档文件(但是,如果zip使用Zip64扩展名,则gunzip的某些安装可能不支持此功能)。例如:

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

也可以将流保存到文件中并使用解压缩。

如果启用了对大文件和归档文件的Zip64支持,并将zip用作过滤器,则zip将创建一个Zip64归档文件,该归档文件需要PKZIP 4.5或更高版本兼容的解压缩来读取该文件。为了避免当前zip标准(PKWARE AppNote)中定义的zip文件结构中存在amgibuities,其中需要在为条目写入数据之前决定使用Zip64,但对于流,此时数据的大小是未知的。如果已知数据小于4GB,可以使用选项-fz-来阻止使用Zip64,但是如果确实需要Zip64,则zip将退出并显示错误。zip 3和unzip 6及更高版本可以读取带有Zip64条目的归档文件。另外,如果在复制归档条目时不需要,zip会删除Zip64扩展名。

将输出定向到另一个文件时,请注意所有选项都应在重定向之前,包括-x。例如:

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

请注意-@列表在macOS上不起作用。

压缩文件

更改现有的zip归档文件时,zip会写入一个包含新内容的临时文件,并且只有在创建新版本的过程顺利完成后才替换旧文件。

如果zip归档文件的名称不包含扩展名,则将添加扩展名.zip。如果名称已经包含.zip以外的扩展名,则现有扩展名保持不变。但是,拆分存档(存档拆分为多个文件)在最后拆分时需要.zip扩展名。

扫描和读取文件

当zip启动时,它会扫描的文件进行处理(如果需要)。如果此扫描花费的时间超过大约5秒钟,则zip会显示“正在扫描文件”消息,并开始每2秒或每处理那么多条目显示进度点,以较长时间为准。如果点之间的间隔超过2秒,则可能表明查找每个文件需要时间,例如,可能意味着网络连接缓慢。(实际上,初始文件扫描是一个两步过程,其中目录扫描后跟一个排序,并且这两个步骤之间用圆点隔开。如果更新现有归档,则在现有文件扫描和新文件扫描。)扫描文件点不受-d控制点大小选项,但是-q&nbp;quiet选项可关闭点。该-f显示文件选项可用于扫描文件,并没有得到实际处理它们扫描的文件列表。

如果zip无法读取文件,它将发出警告,但会继续。有关zip如何处理不匹配的模式和不可读的文件的更多信息,请参见下面的-MM选项。如果跳过了某些文件,则在zip操作结束时会发出一条警告,指出已读取了多少文件以及跳过了多少文件。

命令模式

zip现在支持两种不同的命令模式,外部和内部。外部模式(添加,更新,和清新)(以及从现有的存档)从文件中读取系统文件,而内部模式(删除和复制)在现有的归档专门的条目进行操作。

add 如果存档不存在,请更新现有条目并添加新文件并创建。此选项是默认模式。
update (-u) 更新文件系统上的现有条目(如果较新)并添加新文件。如果存档文件不存在,则发出警告,然后创建新的存档文件。
freshen (-f) 如果文件系统较新,则更新归档文件的现有条目。不将新文件添加到存档中。
delete (-d) 在现有存档中选择条目并将其删除。
copy (-U) 在现有档案中选择条目,然后将其复制到新档案中。这种新模式类似于更新,但是命令行模式会选择现有档案中的条目,而不是文件系统中的文件,并且它使用--out选项将结果档案写入新文件,而不是更新现有档案,从而保留原始存档不变。

新的文件同步选项(-FS)也被认为是一种新模式,尽管它与更新类似。此模式将归档文件与OS上的文件同步,仅当OS文件的文件时间或大小不同时才替换归档文件中的文件,添加新文件,并从没有匹配文件的归档文件中删除条目。由于此模式可以从存档中删除条目,因此请考虑制作存档的备份副本。

拆分档案

zip 3.0版和更高版本可以创建拆分存档。拆分存档是将多个文件拆分为一个标准的zip存档。(请注意,拆分的存档不仅是拆分为多个片段的存档,因为条目的偏移量现在基于每个拆分的开始。将片段合并在一起将使这些偏移量无效,但通常可以通过解压缩来解决。zip通常会拒绝除非使用-FF修复选项来修复偏移量,否则可以处理这样的拼接存档。)

拆分档案的一种用途是将大型档案存储在多个可移动媒体上。对于具有20个拆分文件的拆分存档,文件通常被命名(用存档名称替换ARCHIVE)ARCHIVE.z01,ARCHIVE.z02,...,ARCHIVE.z19,ARCHIVE.zip。请注意,最后一个文件是.zip文件。相反,跨区存档是原始的多磁盘存档,通常需要软盘并使用卷标来存储磁盘编号。压缩支持拆分档案,但不支持跨区档案,尽管存在将正确大小的拆分档案转换为跨区档案的过程。反之亦然,可以将跨区存档的每个文件复制到具有上述名称的文件以创建拆分存档。

使用-s设置拆分大小并创建拆分档案。大小以数字形式给出,然后可选地以k(kB),m(MB),g(GB)或t(TB)之一(默认值为m)。例如,-sp选项可用于在分割之间暂停zip,以允许更改可移动媒体,但请阅读以下有关-s和-sp的描述和警告。

尽管zip不会更新拆分档案,但zip提供了新选项-O(-- output -file或--out),可以更新拆分档案并将其保存在新档案中。例如,

zip inarchive.zip foo.c bar.c --out outarchive.zip

...读取存档inarchive.zip(即使已拆分),添加文件foo.c和bar.c,并将生成的存档写入outarchive.zip。如果inarchive.zip然后拆分outarchive.zip默认为同分大小。请注意,如果outarchive.zip和使用它创建的任何拆分文件已经存在,则始终会根据需要覆盖它们而不会发出警告。将来可能会更改。

Unicode支持

尽管zip标准要求使用特定字符集将路径存储在存档中,但实际上zip会将路径存储在存档中的任何本地字符集。在使用一个字符集的系统上创建或更新归档文件,然后在使用不同字符集的另一系统上提取归档文件时,可能会出现问题。在支持宽字符的平台上启用Unicode支持进行编译时,除了用于向后兼容的标准本地路径外,zip现在还存储UTF-8路径的翻译。这提供了用于存储路径的通用通用字符集,该字符集允许在支持Unicode的其他系统上完全提取这些路径,并在不支持Unicode的系统上尽可能地匹配它们。

在路径内部存储为Unicode但以本地字符集表示的路径的Win32系统上,在本地字符集目录扫描期间可能会跳过某些路径。支持Unicode的zip现在可以读取和存储这些路径。请注意,Win 9x系统和FAT文件系统不完全支持Unicode。

请注意,例如,由于每个操作系统如何切换字符集以进行显示,因此Win32和Unix上的控制台窗口有时无法准确显示所有字符。但是,如果加载了所需的字体,目录导航工具应显示正确的路径。

命令行格式

此版本的zip更新了命令行处理,并支持长选项。

简短选项的形式为:

-s[-][s[-]...][value][=value][ value]

...其中s是一个或两个字符的短选项。接受值的简短选项位于参数的最后,其后的任何内容均作为值。如果可以否定该选项,并且选项后紧跟“ - ”,则该选项无效。短选项也可以作为单独的参数给出

-s[-][value][=value][ value] -s[-][value][=value][ value] ...

通常,短选项将值用作同一参数或以下参数的一部分。还支持可选的=。因此-tt mmddyyyy,-tt = mmddyyyy和-tt mmddyyyy都可以工作。在-x和-i选项接受值的列表,并使用一个稍微不同的格式进行说明。请参阅-x和-i选项。

长选项形式

--longoption [-] [= value] [value]

其中选项以-开头,具有多字符名称,可以包含结尾的破折号以使该选项取反(如果该选项支持),并且可以具有以=开头(无空格)指定的值(选项参数)。值也可以跟在参数后面。所以--before-date = mmddyyyy和--before-date mmddyyyy都可以工作。

长选项名称可以缩写为最短的唯一缩写。请参阅下面的选项说明,其中支持长选项。为避免混淆,如果您打算对它进行取反,请避免在该破折号的缩写处加上一个内嵌破折号(“ - ”)(解析器将考虑尾随的破折号,例如使用--some的选项--some-option)-作为选项,作为名称的一部分而不是一个破折号)。可以更改此值,以强制将来--some-中的最后一个破折号。

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 tarand compress, and it is compatible with PKZIP.

A separate companion program, unzip, unpacks and uncompresses ziparchives. 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.

Usage

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 ziparchive, 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.

Command Format

The basic command format is:

zip options archive inpath inpath ...

...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:

zip -r foo.zip foo

or more concisely:

zip -r foo foo

...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:

foo/file1 
foo/file2

and directory foo has:

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 -@, 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 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:

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 compressed, in which case it will read the file from standard input, allowing 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 zipcan take advantage 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 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:

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 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:

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

Please note that -@ lists do not work on macOS.

Zip Files

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.

Command Modes

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.

Split 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,

zip inarchive.zip foo.c bar.c --out outarchive.zip

...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.

Unicode Support

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:

-s[-][s[-]...][value][=value][ value]

...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

-s[-][value][=value][ value] -s[-][value][=value][ value] ...

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

--longoption[-][=value][ value]

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-optionusing --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.

查看英文版

查看中文版

zip 语法

zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [--longoption...]  [-b path] 
    [-n suffixes] [-t date] [-tt date] [zipfile[file...]]  [-xi list]
选项
-a,-- ascii 在使用EBCDIC的系统上,此选项将文件转换为ASCII格式。
-A,-- adjust-sfx 调整自解压可执行存档。通过将“ SFX”存根放在现有归档文件的前面,可以创建一个自解压的可执行文件归档文件。该-A选项告诉拉链调整存储在归档中的条目偏移考虑到这个“序言”的数据。
-AC,-- archive-clear 此选项是仅Windows选项。创建归档文件后(并测试了是否使用-T,建议这样做),然后清除已处理文件的归档位。一旦清除了这些位,便将其永久清除。您可能需要使用-sf(显示文件)选项来存储已处理文件的列表,以防必须重复执行归档操作。还可以考虑使用-MM(必须匹配)选项。请确保签出-DF作为进行增量备份的可能更好的方法。
-AS,-- archive-set 此选项是仅Windows的选项,仅包含已设置存档位的文件。使用-AS时不会存储目录,但是默认情况下,包括目录的条目路径会照常存储,并且大多数解压缩都可以使用它们来重新创建目录。
修改文件时,操作系统将设置存档位;如果与-AC一起使用,则-AS可提供增量备份功能。但是,其他应用程序可以修改存档位,这可能无法可靠地指示自上次存档操作以来哪些文件已更改。创建增量备份的替代方法是使用-t使用文件日期,尽管这不会捕获复制到正在归档的目录中的旧文件,并且使用-DF创建差异归档。
-B,-- binary 强制将文件读取为二进制文件(默认为文本)。
-b path, --temp-path path 将指定的路径用于临时 zip存档。例如:
zip -b /tmp stuff *
...将临时zip存档放在/ tmp目录中,完成后将stuff.zip复制到当前目录。当更新现有归档文件且包含该旧归档文件的文件系统没有足够的空间同时容纳新旧归档文件时,此选项很有用。在某些情况下进行流传输时,避免使用数据描述符也可能很有用。请注意,使用此选项可能需要zip花费更多时间才能将存档文件复制到目标文件系统。
-c,-- entry-comments 为每个文件添加单行注释。首先完成文件操作(添加,更新),然后提示用户输入每个文件的单行注释。输入评论,然后返回,或者只返回就没有评论。
--d, --delete 从zip存档中删除(删除)条目。例如:
zip -d foo foo / tom / junk foo / harry / \ * \ *。o
...将删除条目foo / tom / junk,所有以foo / harry /开头的文件以及所有以.o结尾的文件(在任何路径中)。请注意,使用反斜杠禁止了shell路径名的扩展,因此zip可以看到星号,从而使zip能够匹配zip存档的内容而不是当前目录的内容。(在基于MSDOS的平台上不使用反斜杠。)也可以使用引号来转义星号,如
zip -d foo foo / tom / junk“ foo / harry / *”“ * .o”
在外壳扩展通配符的系统上不转义星号可能会导致将星号转换为当前目录中的文件列表,并且该列表用于从存档中删除条目。
在MSDOS下,-d与zip归档文件中的名称匹配时区分大小写。如果在MSDOS系统上使用PKZIP压缩了文件名,则需要使用大写形式输入文件名。请参阅选项-ic以忽略归档中的大小写。
-db,-- display-bytes 显示运行字节计数,显示压缩后的字节和要移动的字节。
-dc,-- display-counts 显示压缩的条目的运行计数和尚待处理的条目。
-dd,-- display-dots 压缩每个条目时显示点(具有自己的进度指示器的端口除外)。有关设置点的大小,请参见下面的-ds。默认值为每处理10 MB的输入文件一个点。所述-v选项还显示点(先前在高得多的速率比这个但现在-v也默认为10 MB)和该速率也由控制-ds。
-df,-- datafork 在MacOS上,仅包括压缩到存档中的文件的数据叉。适用于将文件导出到国外操作系统。资源叉将被完全忽略。
-dg,--display-globaldots 显示存档而不是每个文件的进度点。命令
zip -qdgds 10m
...将关闭每10 MB的点以外的大多数输出。
-ds size,-- dot-size size 设置显示的每个点处理的输入文件数量。请参阅-dd以启用显示点。设置此选项意味着-dd。大小采用nm格式,其中n是一个数字,m是一个乘数。当前,m可以是k(KB),m(MB),g(GB)或t(TB);因此,如果n为100且m为k,则大小为100k,即100 KB。默认值为10 MB。
的-v选项也显示点,现在也默认为10 MB。此速率也受此选项控制。甲大小的0匝圆点关闭。
当zip扫描输入文件时,此选项不能控制“扫描文件”消息中的点。其点大小固定为2秒或固定数目的条目,以时间较长者为准。
-du,-- display -help 显示每个条目的未压缩大小。
-dv,-- display-volume 显示正在读取每个条目的卷(磁盘)号,读取现有归档的位置以及写入的位置。
-D, --no-dir-entries 不要在zip存档中为目录创建条目。默认情况下创建目录条目,以便可以将其属性保存在归档中。在环境变量 ZIPOPT可用于更改默认选项。例如在Unix下使用sh:
ZIPOPT="-D"; export ZIPOPT
(变量ZIPOPT可以用于任何选项,包括-i和-x,使用下面将详细介绍的新选项格式,并且可以包括多个选项。)选项-D是-x“ * /”的简写,但以前是后者不能被设置为默认的ZIPOPT为内容的环境变量ZIPOPT被插入到接近命令行的开头和文件列表曾在该行的首尾。如果使用以下格式,则
此版本的zip确实允许在ZIPOPT中使用-x和-i选项:
-x file file ... @
...,其中@(只是@的参数)终止列表。
-DF, --difference-archive 创建一个存档,其中包含自创建原始存档以来的所有新文件和更改过的文件。为此,输入文件列表和当前目录必须与原始zip操作期间的相同。
例如,如果现有存档是使用
zip -r foofull。
从bar目录中,然后输入命令
zip -r foofull。-DF --out foonew
...同样从bar目录中创建存档foonew,其中仅包含不在foofull中的文件,以及文件大小或文件时间与foofull中的文件不匹配的文件。
请注意,应根据本地时区设置时区环境变量TZ,此选项才能正常工作。自从原始存档创建以来,时区的更改可能导致没有时间匹配,并且所有文件都被包括在内。
备份目录的一种可能方法可能是创建目录内容的普通存档作为完整备份,然后使用此选项创建增量备份。
-e, --encrypt 使用在终端上根据提示输入的密码对zip存档的内容进行加密(不会回显;如果标准错误不是tty,则zip会退出并显示错误)。重复密码提示,以免用户输入错误。
-E, --longnames 在OS / 2上,使用.LONGNAME扩展属性(如果找到)作为文件名。
-f,-- freshen 仅当修改过的内容比zip存档中已有的版本最近时,才替换(freshen)zip存档中的现有条目;与更新选项(-u)不同,它不会添加zip存档中尚未存在的文件。例如:
zip -f foo
由于存储在zip归档文件中的路径始终是相对的,因此该命令应从运行原始zip命令的目录中运行。请注意,应根据本地时区设置时区环境变量TZ,以使-f,-u和-o选项正常工作。其背后的原因有些微妙,但与Unix格式的文件时间(总是在GMT中)和大多数其他操作系统(总是在本地时间)之间的差异以及比较这两者的必要性有关。典型的TZ值是“ MET-1MEST”(中欧时间,可自动调整“夏令时”或夏令时)。
格式为TTThhDDD,其中TTT是时区(例如PST),hh是GMT与本地时间之间的时差(例如上面的-1),DDD是夏令时生效的时区。如果没有夏令时,请不要使用DDD。对于美国东部时区:EST5EDT。
-F,-- fix,-FF,-- fixfix 修复zip存档。该-F选项如果归档的某些部分缺失可以使用,但需要一个合理的完整的中央目录。像往常一样扫描输入档案,但是zip忽略了一些问题。生成的存档应该有效,但是所有不一致的条目都将被忽略。
如果在-FF中加倍,则从头开始扫描存档,然后从zip扫描中扫描特殊签名,以识别存档成员之间的限制。如果归档文件损坏不太多,则单个-F更为可靠,因此请首先尝试此选项。
如果归档文件太损坏或末尾被截断,则必须使用-FF。此选项是对zip 2.32的更改,其中-F选项可以读取截断的存档。该-F选项现在更可靠轻微损伤和修复档案-FF选择需要被修复档案,其中-F以前可能已经足够了。
这两个选项都不会恢复以ascii模式而不是二进制模式错误传输的档案。修复之后,unzip的-t选项可能表明某些文件的CRC错误。此类文件无法恢复;您可以使用zip的-d选项将其从存档中删除。注意-FF
可能无法解决包含包含(未压缩)存储在其中的嵌入式zip存档的存档的问题,并且根据损坏的不同,它可能会在嵌入式存档中找到条目,而不是存档本身。首先尝试-F,因为它没有此问题。
修复命令的格式已更改。例如,要修复损坏的存档foo.zip,
zip -F foo --out foofix
...尝试正常读取条目,将正确的条目复制到新的存档foofix.zip中。如果这不起作用(例如存档被截断),或者丢失了您知道的某些条目,请尝试
zip -FF foo --out foofixfix
...并将生成的档案与-F创建的档案进行比较。该-FF选项可以创建一个不一致的存档。根据损坏的内容,然后可以使用-F选项修复该归档文件。如果您有存档的最后一个拆分(.zip文件),
则可以使用-F修复缺少拆分文件的拆分存档。如果缺少此文件,则必须使用-FF修复存档,这将提示您进行拆分。当前,修复选项无法恢复校验和错误或已损坏的条目。
-FI,--fifo 在Unix上,通常zip跳过读取遇到的任何FIFO(称为管道),因为如果未送入FIFO ,zip可能会挂起。此选项告诉zip读取其找到的任何FIFO的内容。
-FS,-- filesync 将归档文件的内容与操作系统上的文件同步。通常,在更新存档时,会添加新文件并更新已更改的文件,但不会从存档中删除OS上不再存在的文件。此选项启用一种新模式,该模式将对照文件系统检查存档中的条目。如果条目的文件时间和文件大小与OS文件的文件时间和文件大小匹配,则从旧归档文件中复制条目,而不是从文件系统中读取并压缩。如果OS文件已更改,则将照常读取和压缩条目。如果存档中的条目与OS上的文件不匹配,则将删除该条目。启用此选项应创建与新档案相同的档案,但是由于复制了现有条目而不是将其压缩,因此请使用-FS更新现有档案比创建新的存档要快得多。还可以考虑使用-u更新档案。
为了使该选项起作用,应该从创建存档的目录中更新存档,以便相对路径匹配。如果要从旧档案中复制文件很少,则创建新档案可能会更快。
请注意,应根据本地时区设置时区环境变量TZ,此选项才能正常工作。自从原始存档创建以来,时区的更改可能不会导致所有文件的匹配和重新压缩时间。
此选项从存档中删除文件。如果需要保留原始档案,请首先复制档案或使用--out选项将更新的存档输出到新文件。尽管可能更慢,但是使用新的存档名称创建新的存档更安全,可以避免存档路径和OS路径不匹配,因此是首选。
-g, --grow 增加(附加到)指定的zip存档,而不是创建一个新的zip存档。如果此操作失败,则zip尝试将存档恢复到其原始状态。如果还原失败,则存档可能已损坏。如果没有现有存档,或者必须更新或删除至少一个存档成员,则忽略此选项。
-h,- ?,--help 显示zip帮助信息(如果zip在不带参数的情况下运行,也会显示该信息)。
-h2, --more-help 显示扩展的帮助,包括更多有关命令行格式,模式匹配和更晦涩的选项的信息。
-i files, --include files 仅包括指定的文件,如:
zip -r foo . -i \*.c
...,它将仅包括当前目录及其子目录中以.c结尾的文件。(对于PKZIP用户请注意:等效命令为
pkzip -rP foo * .c
PKZIP不允许在当前目录以外的目录中进行递归。)反斜杠避免了Shell文件名的替换,因此名称匹配由zip在所有目录级别执行。[此选项适用于Unix和其他系统,其中\会转义下一个字符。]因此,要包含dir(直接在当前目录下的目录),请使用:
zip -r foo . -i dir/\*
要么:
zip -r foo . -i "dir/*"
...以匹配dir / a和dir / b / file.c之类的路径。请注意,目录目前需要尾随/。
zip -r foo . -i dir/
...以包含目录dir)。
第一个示例的长选项格式为:
zip -r foo。--include \ *。c
...和做空期权表格一样。
尽管命令语法以前在命令行末尾需要-i,但是此版本实际上允许在任何地方使用-i(或--include)。文件列表以-,命令行末尾或列表终止符@(仅@的参数)开头的下一个参数终止。因此,以上可以表示为:
zip -i \ *。c @ -r foo。
...例如。选项和列表的第一个文件之间必须有一个空格。对于一个文件,您可以使用单值形式:
zip -i \ *。c -r foo。
(选项和值之间没有空格)或:
zip --include = \ *。c -r foo。
...作为其他示例。不建议使用单值形式,因为它们可能会造成混淆,尤其是-ifile格式如果文件的第一个字母与i组成一个以i开头的两个字母的选项,则可能导致问题。使用-sc查看如何解析您的命令行。
也可能:
zip -r foo。-i@include.lst
...将仅包括当前目录中的文件及其与文件include.lst中的模式匹配的子目录。
到-i和-x的文件是与内部归档路径匹配的模式。有关模式的更多信息,请参见-R。
-I, --no-image 在Acorn RISC OS上,此选项指示zip不要扫描图像文件。使用zip时,它不会将图像文件(例如,加载SparkFS时的DOS分区或Spark归档文件)视为目录,而是将它们存储为单个文件。
例如,如果您已加载SparkFS,则压缩Spark归档文件将导致包含目录(及其内容)的zip文件,而使用' I '选项将导致包含Spark归档文件的zipfile。显然,如果未加载SparkFS,也会获得第二种情况(没有' I '选项)。
-ic,-- ignore-case 在VMS或Windows系统上,匹配归档条目时忽略大小写。该选项仅在忽略文件大小写的系统上可用。在具有不区分大小写的文件系统的系统上,在文件系统上匹配文件时通常忽略大小写,但在与归档文件匹配时,对于-f(freshen),- d(删除),- U(复制)和类似方式不忽略大小写。条目(当前-f忽略VMS上的大小写),因为归档条目可以来自大小写很重要的系统,并且除了归档中可以存在case之外,其他名称都相同。该-IC选项使所有匹配不区分大小写。该选项可能导致多个归档条目与命令行模式匹配。
-j, --junk-paths 仅存储已保存文件的名称(不包含路径),而不存储目录名称。默认情况下,zip将存储相对于当前目录的完整路径。
-jj, --absolute-path 在macOS上,记录Fullpath(+ Volname)。包括音量在内的完整路径将被存储。默认情况下,将存储相对路径。
-J,-- junk-sfx 从存档中剥离所有前置数据(例如SFX存根)。
-k, --DOS-names 尝试转换名称和路径以符合MSDOS,仅存储MSDOS属性(仅是Unix中的用户write属性),然后将该条目标记为在MSDOS下进行(即使不是);为了与MSDOS下的PKUNZIP兼容,MSDOS无法处理某些名称,例如带有两个点的名称。
-l,--to-CRLF 将Unix的行尾字符LF转换为MSDOS约定CR LF。此选项不应在二进制文件上使用。如果zip文件用于MSDOS下的PKUNZIP,则可以在Unix上使用此选项。如果输入文件已经包含CR LF,则此选项将添加一个额外的CR。此选项是为了确保Unix 上的unzip -a将获得原始文件的精确副本,以撤消zip -l的影响。有关如何处理二进制文件,请参见-ll。
-la,-- log-append 追加到现有 日志文件。默认为覆盖。
-lf logfilepath, --logfile-path logfilepath 在给定路径下打开一个日志文件。缺省情况下,该位置上的任何现有文件都将被覆盖,但是-la选项将导致打开现有文件并将新的日志信息附加到任何现有信息中。除非也给出了-li选项,否则仅将警告和错误写入日志,然后所有信息消息也将写入日志。
-li,-- log-info 在日志中包括信息消息,例如压缩的文件名。默认设置是仅包括命令行,所有警告和错误以及最终状态。
-ll,-- from-crlf 将MSDOS行尾CR LF转换为Unix LF。此选项不应在二进制文件上使用。如果该zip文件旨在在Unix下解压缩,则可以在MSDOS上使用此选项。如果文件被转换并且以后被确定为二进制文件,则会发出警告,并且文件可能已损坏。在此版本中,如果-ll在从文件读取的第一个缓冲区中检测到二进制文件,则为zip现在会发出警告,并跳过文件的行尾转换。该检查似乎捕获了所有测试过的二进制文件,但是原始检查仍然存在,并且如果以后确定转换后的文件是二进制文件,则仍会发出警告。现在,一种用于二进制检测的新算法将允许以UTF-8和类似编码的文本文件的行尾转换。
-L, --license 显示zip许可证。
-m, --move 将指定的文件移到zip归档文件中;实际上,这将在创建指定的zip归档文件后删除目标目录/文件。如果目录在删除文件后变为空,则目录也会被删除。直到zip成功创建存档后,才可以进行删除操作。此选项对于节省磁盘空间很有用,但是有潜在的危险,因此建议在删除所有输入文件之前将其与-T结合使用以测试存档。
-MM, --must-match 所有输入模式必须至少匹配一个文件,并且找到的所有输入文件必须可读。通常,当输入模式与文件不匹配时,会发出“名称不匹配”警告,并且当找到输入文件但以后缺少或不可读时,会发出缺少或不可读的警告。在任何一种情况下,zip都会继续创建档案,其中会跳过丢失或无法读取的新文件,并且档案中已经存在的文件保持不变。创建归档文件后,如果任何文件都不可读,则输入格式不匹配(发出“名称不匹配”警告时)或输入文件不可读时,zip将返回OPEN错误代码(在大多数系统上为18),而不是正常的成功返回值(在大多数系统上为0)。带-MM套,拉链退出。在这两种情况下,zip都将退出并显示OPEN错误,并且不会创建任何存档。
当要压缩已知文件列表时,此选项很有用,这样任何丢失或不可读的文件都将导致错误。与通配符一起使用时,它的用处不大,但是,如果任何输入模式与至少一个文件都不匹配,并且任何匹配的文件都不可读,则zip仍然会退出并显示错误。如果仍要创建归档文件,并且只需要知道是否已跳过文件,则不要使用-MM,而只需检查返回代码。此外-LF可能是有益的。
-n suffixes, --suffixes suffixes 不要尝试压缩以给定后缀命名的文件。此类文件存储(0%压缩)在输出zip文件中,因此zip不会浪费时间尝试对其进行压缩。后缀由冒号或分号分隔。例如:
zip -rn .Z:.zip:.tiff:.gif:.snd foo foo
会将foo中的所有内容复制到foo.zip中,但会存储以.Z,.zip,.tiff,.gif或.snd结尾的任何文件,而无需尝试对其进行压缩(图像和声音文件通常具有自己专用的压缩方法)。默认情况下,zip不会压缩列表中带有扩展名.Z:.zip:.zoo:.arc:.lzh:.arj的文件。这些文件直接存储在输出档案中。环境变量ZIPOPT可用于更改默认选项。例如在Unix下使用csh:
setenv ZIPOPT“ -n .gif:.zip”
要尝试压缩所有文件,请使用:
zip -n:foo
最大压缩选项-9也会尝试对所有文件进行压缩,而不管扩展名如何。
在Acorn RISC OS系统上,后缀实际上是文件类型(3个十六进制数字格式)。默认情况下,zip不会压缩列表DDC:D96:68E中具有文件类型的文件(即,存档,CFS文件和PackDir文件)。
-nw,-- no-wild 不要执行内部通配符处理(除非对参数进行转义,否则外壳仍会对通配符进行shell处理)。如果正在读取路径列表并且不需要通配符替换,则很有用。
-N,-- notes [Amiga,MacOS]将Amiga或MacOS文件注释另存为zipfile注释。可以使用unzip的-N选项恢复它们。如果还使用-c,则提示您仅对那些没有文件注释的文件进行注释。
-o, --latest-time 设定的“最后修改”时间压缩归档到最新版本(旧)“最后修改”时间在条目中发现的zip压缩文件。如果需要,可以在没有任何其他操作的情况下使用此选项。例如:
zip -o foo
...的最后修改时间会改变foo.zip在条目的最晚时间foo.zip。
-O output-file, --output-fileoutput-file 照常处理存档更改,但不要更新现有存档,而是将新存档输出到输出文件。这对于在不更改现有档案的情况下更新档案非常有用,并且输入档案必须是与输出档案不同的文件。
此选项可用于创建更新的拆分存档。它也可以与-U一起使用,以将条目从现有归档复制到新归档。
另一个用途是将zip文件从一种拆分大小转换为另一种拆分大小。例如,要将具有700 MB CD拆分的存档转换为具有2 GB DVD拆分的存档,可以使用:
zip -s 2g cd-split.zip --out dvd-split.zip
...使用复制模式。请参阅下面的-U。也:
zip -s 0 split.zip --out unsplit.zip

...会将分割后的存档转换为单文件存档。
复制模式会将流条目(使用数据描述符并且应与大多数解压缩兼容)转换为普通条目(应与所有解压缩兼容),除非使用了标准加密。对于具有加密条目的档案,zipcloak将解密条目并将其转换为普通条目。

-p, --paths 将相对文件路径作为归档中存储的文件名的一部分。此选项是默认选项。该-j选项侧畔的路径,只是存储文件的名称。
-P password, --passwordpassword 使用密码来加密的压缩文件条目(如果有的话)。这是不安全的!许多多用户操作系统为任何用户提供了查看其他任何用户的当前命令行的方法。即使在独立系统上,也始终存在过度偷看的威胁。将纯文本密码作为命令行的一部分存储在自动化脚本中的情况更加糟糕。只要有可能,请使用非回声的交互式提示输入密码。(在真正意义上的安全性方面,请使用诸如“很好的隐私”之类的强加密方法,而不要使用zipfile实用程序提供的相对较弱的标准加密方法。)
-q, --quiet 静音模式; 消除参考消息和评论提示。(例如,在shell脚本和后台任务中很有用)。
-r, --recurse-paths 递归地移动目录结构;例如:
zip -r foo.zip foo
或更简洁
zip -r foo foo
在这种情况下,由于递归不使用Shell的文件名替换机制,因此foo中的所有文件和目录都保存在名为foo.zip的档案中,包括名称以“。 ” 开头的文件。如果只想在目录foo及其子目录中包括文件的特定子集,请使用-i选项指定要包括的文件模式。您不应该使用名称为“。* ”的-r,因为它与“ .. ” 匹配,后者将尝试压缩父目录(可能不是预期的目录)。允许多个源目录:
zip -r foo foo1 foo2
...首先将foo1压缩,然后将foo2压缩,分别进入每个目录。
请注意,虽然在递归文件系统中的目录时通常会解析到-r的通配符,但是一旦扫描目录,任何-R,-x和-i通配符都将应用于内部归档路径名。要使通配符适用于在Shell进行通配符替换的Unix和类似系统上递归时在子目录中的文件,请转义所有通配符或将所有带有通配符的参数放在引号中。这使得zip可以看到通配符,并在递归时使用通配符来匹配子目录中的文件。
-R, --recurse-patterns 从当前目录开始递归地移动目录结构;例如:
zip -R foo“ * .c”
在这种情况下,从当前目录开始的树中所有与* .c匹配的文件都存储在名为foo.zip的zip归档文件中。请注意,* .c将匹配file.c,a / file.c和a / b / .c。可以将多个模式作为单独的参数列出。PKZIP用户注意:等效命令为
pkzip -rP foo * .c
模式是它们在存档中出现时的相对文件路径,或在压缩后将成为相对文件路径,并且可以在其中包含可选的通配符。例如,给定当前目录为foo,在其下为目录foo1和foo2,在foo1中为文件bar.c,
zip -R foo/*
...将压缩foo,foo / foo1,foo / foo1 / bar.c和foo / foo2。
zip -R */bar.c
...将拉链拉上富/ foo1 / bar.c。请参阅-r关于转义通配符的注释。
-RE,-- regex [WIN32]在zip 3.0 之前,Windows平台上默认启用正则表达式列表匹配。由于需要对名称中的“ [”和“ ] ” 进行转义而造成的混乱,因此Windows默认情况下已将其关闭,因此“ [ ”和“ ] ”只是名称中的普通字符。此选项再次启用[]匹配。
-s splitsize,-- split-size splitsize 启用创建拆分存档并设置拆分大小。拆分存档是可以拆分为多个文件的存档。创建归档文件时,如果归档文件的大小达到指定的拆分大小,则将关闭该拆分,然后打开下一个拆分。通常,除最后一个分割以外,所有分割都是分割大小,最后一个将是剩余的大小。如果整个档案小于拆分的大小,则会创建一个单文件档案。
拆分的归档文件存储在编号文件中。例如,如果输出归档文件名为archive且需要三个拆分,则生成的归档文件将位于三个文件archive.z01,archive.z02和archive.zip中。。请勿更改这些文件的编号,否则存档将不可读,因为这些文件用于确定拆分的读取顺序。
分割大小是一个数字,可以选择后面跟一个乘数。当前数字必须是整数。乘数当前可以是k(千字节),m(兆字节),g(千兆字节)或t(兆字节)之一。由于最小拆分大小为64 k,因此不带乘数的数字默认为兆字节。例如,要创建一个名为foo的拆分存档,其中bar目录的内容拆分为670 MB,这对于在CD上刻录可能很有用,请使用以下命令:
zip -s 670m -r foo bar
可用于。
当前,拆分存档中的旧拆分未从新存档中排除,但可以专门将其排除。如果可能,在创建拆分归档文件时,请将输入和输出归档文件放在压缩路径之外。如上所述,在不
使用-sp的情况下使用-s会创建所有要写入foo的拆分,在本例中为当前目录。此拆分模式会在创建存档时更新拆分,要求所有拆分保持可写状态,但是会创建支持任何拆分存档的解压缩都可读取的拆分存档。请参阅下面的-sp以启用拆分暂停模式,该模式允许将拆分直接写入可移动介质。选项
-sv可用于启用详细拆分,并提供有关拆分方式的详细信息。该-sb选项可用于下一分割目的地拉链暂停时铃。
拆分档案无法更新,但是请参见-O(-- out)选项,以了解如何在将拆分档案复制到新档案时对其进行更新。也可以使用拆分大小为0或否定-s选项将拆分存档转换为单文件存档:
zip -s 0 split.zip --out single.zip
有关使用复制模式的更多信息,请参见-U(-- copy)。
-sb,-- split-bell 如果进行拆分并使用拆分暂停模式,则在每个拆分目标的zip暂停时响铃。
-sc,-- show-command 将命令行开头的zip显示为已处理并退出。新的命令解析器对参数进行置换,将所有选项和与它们关联的任何值放在任何非选项参数之前,这允许选项出现在命令行中的任何位置,只要该选项附带的任何值都包含在其中。此选项以zip所见的方式显示命令行,包括环境中的任何参数,例如ZIPOPT变量。在允许的情况下,命令行后面的选项可以覆盖命令行前面的选项。
-sf,-- show-files 显示将要操作的文件,然后退出。例如,如果创建一个新的归档文件,它将列出要添加的文件。如果否定该选项(-sf-),则仅输出到打开的日志文件。不建议将屏幕显示用于大型列表。
-so,-- show-options 显示在当前系统上编译时zip支持的所有可用选项。当此命令读取选项表时,它应包括所有选项。每行包括short选项(如果已定义),long选项(如果已定义),该选项随附的任何值的格式(如果可以取反该选项)以及简短说明。值格式可以是无值,必需值,可选值,单个字符值,数字值或值列表。此选项的输出并非旨在显示如何使用任何选项,而仅显示可用的选项。
-sp,-- split-pause 如果使用-s启用了拆分,请启用拆分暂停模式。此选项与-s一样创建拆分归档文件,但是使用流写入功能,因此可以在写入每个拆分后立即关闭每个拆分,并且zip将在每个拆分之间暂停,以允许更改拆分目标或媒体。
尽管此拆分模式允许将拆分直接写入可移动媒体,但它使用的流存档格式可能无法被某些解压缩文件读取。在依赖使用-sp创建的拆分之前,请使用将要使用的unzip测试拆分档案。
要将流拆分存档(使用-sp创建)转换为标准存档,请参见--out选项。
-su,-- show-unicode 作为-sf,还显示路径的Unicode版本(如果存在)。
-sU,-- show -just-unicode 作为-sf,但仅显示路径的Unicode版本(如果存在),否则显示路径的标准版本。
-sv,-- split-verbose 拆分时启用各种详细消息,以显示拆分过程。
-S,-- system-hidden 包括系统文件和隐藏文件。在MacOS上,包括finder不可见文件,否则将被忽略。
-t mmddyyyy, --from-datemmddyyyy 不要在指定的日期,其中前修改的文件操作毫米是月份(00 -12),DD是月(当天01 - 31)和YYYY是年份。也接受ISO 8601日期格式yyyy - mm - dd。例如:
zip -rt 12071991 infamy foo
zip -rt 1991-12-07 infamy foo
...会将foo及其子目录中最后修改于1991年12月7日或之后的所有文件添加到zip档案infamy.zip中。
-tt mmddyyyy,--before-date mmddyyyy 不要在后或在指定的日期,在修改过的文件进行操作毫米是月份(00 - 12),DD是月(当天01 - 31)和YYYY是年份。也接受ISO 8601日期格式yyyy - mm - dd。例如:
zip -rtt 11301995 infamy foo
zip -rtt 1995-11-30 infamy foo
...会将foo及其子目录中所有在1995年11月30日之前最后修改的文件添加到zip档案infamy.zip中。
-T,--test 测试新的zip文件的完整性。如果检查失败,则旧的zip文件不会更改,并且(使用-m选项)不会删除任何输入文件。
-TT cmd, --unzip-command cmd 使用-T选项时,请使用命令cmd而不是' unzip -tqq '测试存档。在Unix上,要在当前目录中使用unzip副本代替标准系统unzip,可以使用:
zip archive file1 file2 -T -TT "./unzip -tqq"
在cmd中,{}将替换为临时存档的名称,否则存档的名称将附加到命令的末尾。检查返回码是否成功(在Unix上为0)。
-u,--update 仅在修改了比zip归档文件中已有的版本最近的情况下,才替换(更新)zip归档文件中的现有条目。例如:
zip -u stuff *
...将在当前目录中添加任何新文件,并更新自从zip存档stuff.zip上次创建/修改以来已被修改的所有文件(请注意,当您执行此操作时,zip不会尝试将stuff.zip打包到自身中这个)。
请注意,没有输入文件参数的-u选项的作用类似于-f(freshen)选项。
-U,-- copy-entries 将条目从一个存档复制到另一个。需要--out选项来指定与输入档案不同的输出文件。复制模式与-d(删除)相反。当将--out与delete一起使用时,会将所选条目从存档中删除,并将所有其他条目复制到新存档中,而复制模式则选择要包含在新存档中的文件。与-u(更新)不同,命令行上的输入模式仅与归档条目匹配,而不与文件系统文件匹配。例如,
zip不存档“ * .c” --copy --out不存档
...将名称以.c结尾的条目从无归档复制到无归档。在某些系统上,必须对通配符进行转义,以防止Shell替换文件系统中文件的文件名,而文件名可能与存档中的条目无关。
如果命令行上没有输入文件,并且使用了--out,则假定为复制模式:
zip inarchive "*.c" --copy --out outarchive
例如,此选项对于更改拆分大小很有用。使用复制模式尚不支持加密和解密条目。为此使用zipcloak。
-UN v,-- unicode v 确定zip应该使用Unicode文件名。如果输入路径不完全是7位ASCII,则除了标准文件路径之外,zip 3.0现在还包括该路径的UTF-8转换。当条目缺少Unicode路径时,zip会还原为标准文件路径。使用标准路径的问题是此路径位于创建条目的zip的本地字符集中,其中可能包含在unzip使用的字符集中无效的字符。当zip读取存档时,如果条目也具有Unicode路径,则拉链现在默认使用当前本地字符集使用Unicode路径重新创建标准路径。
如果存储的标准路径和存储的UTF-8路径不匹配(如果更新了标准路径,则可能会发生此问题),此选项可用于确定该路径应使用哪种zip。在所有情况下,如果存在不匹配,则假定标准路径为最新路径,而zip使用该路径。如果值v是
q 如果路径不匹配,则退出
w 警告,继续使用标准路径
i世 忽略,继续使用标准路径
n 没有Unicode,请勿使用Unicode路径
默认为警告并继续。
当前字符集中无效的字符被转义为#U xxxx和#L xxxxxx,其中x是十六进制数字的ASCII字符。如果16位字符号足以表示Unicode字符,则使用第一个字符;如果该字符需要16位以上的字符来表示其Unicode字符代码,则使用第二个字符。将-UN设置为
e escape
如:
zip archive -sU -UN=e
...强制zip转换所有不可打印的7位ASCII字符。
通常,zip将UTF-8直接存储在系统(其中UTF-8是当前字符集)的标准路径字段中,否则将UTF-8存储在新的额外字段中。选项
u UTF-8

zip archive dir -r -UN=UTF8
...强制zip将UTF-8存储为本地文件。请注意,直接存储UTF-8是支持它的Unix系统的默认设置。此选项在Windows系统上可能有用,在Windows系统中,转义路径太大而不能成为有效路径,并且路径的UTF-8版本较小,但是本机UTF-8在Windows系统上不向后兼容。
-v,-- verbose 详细模式或打印诊断版本信息。
通常,当应用于实际操作时,此选项可在压缩期间显示进度指示器(有关点的更多信息,请参见-dd),并请求有关zipfile结构异常的详细诊断信息。
但是,当 -v是唯一打印诊断屏幕的命令行参数。即使将stdout重定向到文件,这现在也应该起作用,从而可以轻松保存信息,以将错误报告发送到Info-ZIP。版本屏幕为帮助屏幕标题提供程序名称,版本和发行日期,指向Info-ZIP主页和发行站点的一些指针,并显示有关目标环境的信息(编译器类型和版本,操作系统版本,编译日期和用于创建zip可执行文件的已启用可选功能)。
-V, --VMS-portable 在VMS上,保存VMS文件属性。(在EOF处文件被截断。)在非VMS系统上解压缩-V归档文件时,应完整提取某些文件类型(尤其是Stream_LF文本文件和纯二进制文件,如fixed-512)。具有嵌入式记录大小的索引文件和文件类型(尤其是可变长度记录类型)可能会在其他地方被视为损坏。
-VV, --VMS-specific 在VMS上,保存VMS文件属性以及文件中所有分配的块,包括EOF以外的任何数据。对于在VMS系统之间移动格式错误的文件很有用。在非VMS系统上解压缩-VV存档时,几乎所有文件都将损坏。
-w,-- VMS-versions 在VMS上,将文件的版本号附加到名称中,包括文件的多个版本。默认为仅使用指定文件的最新版本。
-ww,-- VMS-dot-versions 在VMS上,使用来将文件的版本号附加到名称中,包括文件的多个版本。nnn格式。默认为仅使用指定文件的最新版本。
-ws,-- wild-stop-dirs 通配符仅在目录级别匹配。通常zip将路径作为字符串处理,并给出路径
/foo/bar/dir/file1.c/foo/bar/file2.c
输入模式,例如
/ foo / bar / *
通常会匹配两个路径,*匹配dir / file1.c和file2.c。请注意,在第一种情况下,比赛中跨越了目录边界(/)。使用-ws时,匹配中将不包含目录范围,从而使通配符位于特定目录级别的本地。因此,启用-ws后,将仅匹配第二条路径。
当使用-ws,使用**跨目录边界匹配为*一般不会。
-x files, --exclude files 明确排除指定的文件,如:
zip -r foo foo -x \ *。o
...将在foo.zip中包含foo的内容,同时排除所有以.o结尾的文件。反斜杠避免了Shell文件名的替换,因此名称匹配由zip在所有目录级别执行。
也可能:
zip -r foo foo -x@exclude.lst
...将在foo.zip中包含foo的内容,同时排除与文件exclude.lst中的模式匹配的所有文件。以上的长期权形式是
zip -r foo foo --exclude \*.o

zip -r foo foo --exclude @exclude.lst
可以指定多种模式,如:
zip -r foo foo -x \ *。o \ *。c
如果-x与模式之间没有空格,则仅假设一个值(无列表):
zip -r foo foo -x\*.o
有关包括和排除的更多信息,请参见-i。
-X,-- no-extra 不要保存额外的文件属性(在OS / 2上为扩展属性,在Unix上为uid / gid和文件时间)。该ZIP格式使用额外的字段,包括各条目的附加信息。一些额外的字段特定于特定系统,而其他字段则适用于所有系统。通常,当zip从现有存档中读取条目时,它会读取它知道的其他字段,剥离其余部分,并添加适用于该系统的其他字段。使用-X时,zip会删除所有旧字段,并且仅包含Unicode和Zip64额外字段(当前不能禁用这两个额外字段)。
否定此选项-X-,将包括所有默认的额外字段,但还会复制所有无法识别的额外字段。
-y, --symlinks 对于UNIX和VMS(V8.3及更高版本),将符号链接存储在zip归档中,而不是压缩和存储该链接所引用的文件。此选项可避免zip文件递归目录树并直接和通过链接访问文件,从而避免文件中包含文件的多个副本。
-z, --archive-comment 提示对整个zip归档文件进行多行注释。注释以仅包含句点或文件条件结尾的行结束(在Unix上为^ D,在MSDOS,OS / 2和VMS上为^ Z)。可以从文件中获取注释:
zip -z foo < foowhat
-Z cm, --compression-method cm 设置默认的压缩方法。当前,zip支持的主要方法是存储和放气。压缩方式可以设置为:

store 将压缩方法设置为存储将强制zip存储无压缩的条目。此方法通常比压缩条目更快,但是不会节省空间。此方法与使用-0(压缩级别为零)相同。
deflate 此方法是zip的默认方法。如果zip确定存储胜于通缩,则将存储该条目。
bzip2 如果编译了bzip2支持,此压缩方法也将可用。当前只有一些现代的解压缩支持bzip2压缩方法,因此在使用此方法依赖压缩文件之前,请测试将要使用的解压缩(压缩方法12)。
例如,使用bzip2压缩将bar.c添加到存档foo中:
zip -Z bzip2 foo bar.c
压缩方法可以缩写为:
zip -Zb foo bar.c
-# 使用0到9之间的指定数字#调节压缩速度,其中-0表示无压缩(存储所有文件),- 1表示最快的压缩速度(较少压缩),而-9表示最慢的压缩速度(最佳压缩) ,则忽略后缀列表)。默认压缩级别为-6。尽管仍在工作,但目的是此设置将控制所有压缩方法的压缩速度。当前仅控制放气。
-!,-- use-privileges 在Windows上,使用特权(如果已授予)获得WinNT安全性的所有方面。
-@,-- names-stdin 从标准输入中获取输入文件的列表。每行只有一个文件名。
-$,-- volume-label 包含用于保存第一个要压缩文件的驱动器的卷标。如果要仅包含卷标或强制使用特定驱动器,请使用驱动器名称作为第一个文件名,如下所示:
zip-$ foo a:c:bar
环境

zip使用以下环境变量:

ZIPOPT 包含运行zip时将使用的默认选项。该环境变量的内容将在zip命令之后添加到命令行中。
ZIP ZIPOPT的别名,但RISC OS和VMS除外。

在Risc和VMS上,还有其他特殊环境变量。有关详细信息,请查阅您的文档。

zip [-aABcdDeEfFghjklLmoqrRSTuvVwXyz!@$] [--longoption...]  [-b path] 
    [-n suffixes] [-t date] [-tt date] [zipfile[file...]]  [-xi list]
Options
-a, --ascii On systems using EBCDIC, this option translates files to ASCIIformat.
-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 bitsof 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.
-B, --binary Force files to be read as binary (default is text).
-b path, --temp-path path Use the specified path for the temporary zip archive. For example:

zip -b /tmp stuff *
...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.
-c, --entry-comments Add one-line comments for each file. File operations (adding, updating) are done first, and the user is then prompted for a one-line comment for each file. Enter the comment followed by return, or just return for no comment.
-d, --delete Remove (delete) entries from a zip archive. For example:

zip -d foo foo/tom/junk foo/harry/\* \*.o
...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

zip -d foo foo/tom/junk "foo/harry/*" "*.o"
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 -icto ignore case in the archive.
-db, --display-bytes Display running byte counts showing the bytes zipped and the bytes to go.
-dc, --display-counts Display a running count of entries zipped and entries still to be processed.
-dd, --display-dots Display dots while each entry is zipped (except on ports that have their own progress indicator). See -ds below for setting dot size. The default is a dot every 10 MB of input file processed. The -voption also displays dots (previously at a much higher rate than this but now -v also defaults to 10 MB) and this rate is also controlled by -ds.
-df, --datafork On MacOS, include only data-fork of files zipped into the archive. Good for exporting files to foreign operating-systems. Resource-forks will be ignored at all.
-dg, --display-globaldots Display progress dots for the archive instead of for each file. The command

zip -qdgds 10m
...will turn off most output except dots every 10 MB.
-ds size, --dot-size size Set amount of input file processed for each dot displayed. See -ddto enable displaying dots. Setting this option implies -dd. Size is in the format nm where n is a number and m is a multiplier. Currently m can be k (KB), m (MB), g (GB), or t (TB); so if n is 100 and m is k, size would be 100k which is 100 KB. The default is 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 0 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.
-du, --display-usize Display the uncompressed size of each entry.
-dv, --display-volume Display the volume (disk) number each entry is being read from, if reading an existing archive, and where it's being written.
-D, --no-dir-entries Do not create entries in the zip archive for directories. Directory entries are created by default so that their attributes can be saved in the archive. The environment variable ZIPOPT can be used to change the default options. For example under Unix with sh:

ZIPOPT="-D"; export ZIPOPT
(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

-x file file ... @
...is used, where the @ (an argument that is just @) terminates the list.
-DF, --difference-archive Create an archive that contains all new and changed files since the original archive was created. For this to work, the input file list and current directory must be the same as during the original zipoperation.

For example, if the existing archive was created using

zip -r foofull .
from the bar directory, then the command

zip -r foofull . -DF --out foonew
...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.
-e, --encrypt Encrypt the contents of the zip archive using a password that is entered on the terminal in response to a prompt (this will not be echoed; if standard error is not a tty, zip will exit with an error). The password prompt is repeated to save the user from typing errors.
-E, --longnames On OS/2, use the .LONGNAME Extended Attribute (if found) as the file name.
-f, --freshen Replace (freshen) an existing entry in the zip archive only if it has been modified more recently than the version already in the ziparchive; unlike the update option (-u) this will not add files that are not already in the zip archive. For example:

zip -f foo
This command should be run from the same directory from which the original zip command was run, since paths stored in ziparchives 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.
-F, --fix, -FF, --fixfix Fix the zip archive. The -F option can be used if some portions of the archive are missing, but requires a reasonably intact central directory. The input archive is scanned as usual, but zip ignores some problems. The resulting archive should be valid, but any inconsistent entries will be left out.

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 -Foption 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 -toption 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,

zip -F foo --out foofix
...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

zip -FF foo --out foofixfix
...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.
-FI, --fifo On Unix, normally zip skips reading any FIFOs (named pipes) encountered, as zip can hang if the FIFO is not being fed. This option tells zip to read the contents of any FIFO it finds.
-FS, --filesync Synchronize the contents of an archive with the files on the OS. Normally when an archive is updated, new files are added and changed files are updated but files that no longer exist on the OS are not deleted from the archive. This option enables a new mode that checks entries in the archive against the file system. If the file time and file size of the entry matches that of the OS file, the entry is copied from the old archive instead of being read from the file system and compressed. If the OS file has changed, the entry is read and compressed as usual. If the entry in the archive does not match a file on the OS, the entry is deleted. Enabling this option should create archives that are the same as new archives, but since existing entries are copied instead of compressed, updating an existing archive with -FS can be much faster than creating a new archive. Also consider using -u for updating an archive.

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.
-g, --grow Grow (append to) the specified zip archive, instead of creating a new one. If this operation fails, zip attempts to restore the archive to its original state. If the restoration fails, the archive might become corrupted. This option is ignored when there's no existing archive or when at least one archive member must be updated or deleted.
-h, -?, --help Display the zip help information (this also appears if zip is run with no arguments).
-h2, --more-help Display extended help including more on command line format, pattern matching, and more obscure options.
-i files, --include files Include only the specified files, as in:

zip -r foo . -i \*.c
...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 -rP foo *.c
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:

zip -r foo . -i dir/\*
or:

zip -r foo . -i "dir/*"
...to match paths such as dir/a and dir/b/file.c. Note that currently the trailing / is needed for directories (as in:

zip -r foo . -i dir/
...to include directory dir).

The long option form of the first example is:

zip -r foo . --include \*.c
...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:

zip -i \*.c @ -r foo .
...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:

zip -i\*.c -r foo .
(no space between option and value) or:

zip --include=\*.c -r foo .
...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.

Also possible:

zip -r foo  . -i@include.lst
...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.
-I, --no-image On Acorn RISC OS, this option instructs zip not to scan through Image files. When used, zip will not consider Image files (eg. DOS partitions or Spark archives when SparkFS is loaded) as directories but will store them as single files.

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.
-ic, --ignore-case On VMS or Windows systems, ignore case when matching archive entries. This option is only available on systems where the case of files is ignored. On systems with case-insensitive file systems, case is normally ignored when matching files on the file system but is not ignored for -f (freshen), -d (delete), -U (copy), and similar modes when matching against archive entries (currently -f ignores case on VMS) because archive entries can be from systems where case does matter and names that are the same except for case can exist in an archive. The -ic option makes all matching case insensitive. This option can result in multiple archive entries matching a command line pattern.
-j, --junk-paths Store just the name of a saved file (without the path), and do not store directory names. By default, zip will store the full path, relative to the current directory.
-jj, --absolute-path On macOS, record Fullpath (+ Volname). The complete path including volume will be stored. By default the relative path will be stored.
-J, --junk-sfx Strip any prepended data (e.g., a SFX stub) from the archive.
-k, --DOS-names Attempt to convert the names and paths to conform to MSDOS, store only the MSDOS attribute (just the user write attribute from Unix), and mark the entry as made under MSDOS (even though it was not); for compatibility with PKUNZIP under MSDOS which cannot handle certain names such as those with two dots.
-l, --to-crlf Translate the Unix end-of-line character LF into the MSDOS convention CR LF. This option should not be used on binary files. This option can be used on Unix if the zip file is intended for PKUNZIP under MSDOS. If the input files already contain CR LF, this option adds an extra CR. This option is to ensure that unzip -a on Unix will get back an exact copy of the original file, to undo the effect of zip -l. See -ll for how binary files are handled.
-la, --log-append Append to existing logfile. Default is to overwrite.
-lf logfilepath, --logfile-path logfilepath Open a logfile at the given path. By default any existing file at that location is overwritten, but the -la option will result in an existing file being opened and the new log information appended to any existing information. Only warnings and errors are written to the log unless the -li option is also given, then all information messages are also written to the log.
-li, --log-info Include information messages, such as file names being zipped, in the log. The default is to only include the command line, any warnings and errors, and the final status.
-ll, --from-crlf Translate the MSDOS end-of-line CR LF into Unix LF. This option should not be used on binary files. This option can be used on MSDOS if the zip file is intended for unzip under Unix. If the file is converted and the file is later determined to be binary a warning is issued and the file is probably corrupted. In this release if -lldetects binary in the first buffer read from a file, zip now issues a warning and skips line end conversion on the file. This check seems to catch all binary files tested, but the original check remains and if a converted file is later determined to be binary that warning is still issued. A new algorithm is now being used for binary detection that should allow line end conversion of text files in UTF-8 and similar encodings.
-L, --license Display the zip license.
-m, --move Move the specified files into the zip archive; actually, this deletes the target directories/files after making the specified zip archive. If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without error. This option is useful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files.
-MM, --must-match All input patterns must match at least one file and all input files found must be readable. Normally when an input pattern does not match a file the "name not matched" warning is issued and when an input file has been found but later is missing or not readable a missing or not readable warning is issued. In either case zipcontinues creating the archive, with missing or unreadable new files being skipped and files already in the archive remaining unchanged. After the archive is created, if any files were not readable, zipreturns the OPEN error code (18 on most systems) instead of the normal success return (0 on most systems). With -MM set, zip exits as soon as an input pattern is not matched (whenever the "name not matched" warning would be issued) or when an input file is not readable. In either case zip exits with an OPEN error and no archive is created.

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.
-n suffixes, --suffixes suffixes Do not attempt to compress files named with the given suffixes. Such files are stored (0% compression) in the output zip file, so that zip doesn't waste its time trying to compress them. The suffixes are separated by either colons or semicolons. For example:

zip -rn .Z:.zip:.tiff:.gif:.snd  foo foo
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:

setenv ZIPOPT "-n .gif:.zip"
To attempt compression on all files, use:

zip -n : foo
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 hexdigit format). By default, zip does not compress files with filetypes in the list DDC:D96:68E (i.e. Archives, CFS files and PackDir files).
-nw, --no-wild Do not perform internal wildcard processing (shell processing of wildcards is still done by the shell unless the arguments are escaped). Useful if a list of paths is being read and no wildcard substitution is desired.
-N, --notes [Amiga, MacOS] Save Amiga or MacOS filenotes as zipfile comments. They can be restored by using the -N option of unzip. If -c is used also, you are prompted for comments only for those files that do not have filenotes.
-o, --latest-time Set the "last modified" time of the zip archive to the latest (oldest) "last modified" time found among the entries in the zip archive. This option can be used without any other operations, if desired. For example:

zip -o foo
...will change the last modified time of foo.zip to the latest time of the entries in foo.zip.
-O output-file, --output-fileoutput-file Process the archive changes as usual, but instead of updating the existing archive, output the new archive to output-file. Useful for updating an archive without changing the existing archive and the input archive must be a different file than the output archive.

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:

zip -s 2g cd-split.zip --out dvd-split.zip
...which uses copy mode. See -U below. Also:

zip -s 0 split.zip --out unsplit.zip

...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.

-p, --paths Include relative file paths as part of the names of files stored in the archive. This option is the default. The -j option junks the paths and just stores the names of the files.
-P password, --passwordpassword Use password to encrypt zipfile entries (if any). THIS IS INSECURE! Many multi-user operating systems provide ways for any user to see the current command line of any other user; even on stand-alone systems there is always the threat of over-the-shoulder peeking. Storing the plaintext password as part of a command line in an automated script is even worse. Whenever possible, use the non-echoing, interactive prompt to enter passwords. (And where security is truly important, use strong encryption such as Pretty Good Privacy instead of the relatively weak standard encryption provided by zipfile utilities.)
-q, --quiet Quiet mode; eliminate informational messages and comment prompts. (Useful, for example, in shell scripts and background tasks).
-r, --recurse-paths Travel the directory structure recursively; for example:

zip -r foo.zip foo
or more concisely

zip -r foo foo
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:

zip -r foo foo1 foo2
...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.
-R, --recurse-patterns Travel the directory structure recursively starting at the current directory; for example:

zip -R foo "*.c"
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

pkzip -rP foo *.c
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 foo1and foo2 and in foo1 is the file bar.c,

zip -R foo/*
...will zip up foo, foo/foo1, foo/foo1/bar.c, and foo/foo2.

zip -R */bar.c
...will zip up foo/foo1/bar.c. See the note for -r on escaping wildcards.
-RE, --regex [WIN32] Before zip 3.0, regular expression list matching was enabled by default on Windows platforms. Because of confusion resulting from the need to escape "[" and "]" in names, it is now off by default for Windows so "[" and "]" are just normal characters in names. This option enables [] matching again.
-s splitsize, --split-size splitsize Enable creating a split archive and set the split size. A split archive is an archive that could be split over many files. As the archive is created, if the size of the archive reaches the specified split size, that split is closed and the next split opened. In general all splits but the last will be the split size and the last will be whatever is left. If the entire archive is smaller than the split size a single-file archive is created.

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:

zip -s 670m -r foo bar
could be used.

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:

zip -s 0 split.zip --out single.zip
Also see -U (--copy) for more on using copy mode.
-sb, --split-bell If splitting and using split pause mode, ring the bell when zippauses for each split destination.
-sc, --show-command Show the command line starting zip as processed and exit. The new command parser permutes the arguments, putting all options and any values associated with them before any non-option arguments, which allows an option to appear anywhere in the command line as long as any values that go with the option go with it. This option displays the command line as zip sees it, including any arguments from the environment such as from the ZIPOPT variable. Where allowed, options later in the command line can override options earlier in the command line.
-sf, --show-files Show the files that would be operated on, then exit. For instance, if creating a new archive, this will list the files that would be added. If the option is negated (-sf-), output only to an open log file. Screen display is not recommended for large lists.
-so, --show-options Show all available options supported by zip as compiled on the current system. As this command reads the option table, it should include all options. Each line includes the short option (if defined), the long option (if defined), the format of any value that goes with the option, if the option can be negated, and a small description. The value format can be no value, required value, optional value, single character value, number value, or a list of values. The output of this option is not intended to show how to use any option but only show what options are available.
-sp, --split-pause If splitting is enabled with -s, enable split pause mode. This option creates split archives as -s does, but stream writing is used so each split can be closed as soon as it is written and zip will pause between each split to allow changing split destination or media.

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.
-su, --show-unicode As -sf, but also show Unicode version of the path if exists.
-sU, --show-just-unicode As -sf, but only show Unicode version of the path if exists, otherwise show the standard version of the path.
-sv, --split-verbose Enable various verbose messages while splitting, showing how the splitting is being done.
-S, --system-hidden Include system and hidden files. On MacOS, includes finder invisible files, which are ignored otherwise.
-t mmddyyyy, --from-datemmddyyyy Do not operate on files modified prior to the specified date, where mm is the month (00-12), dd is the day of the month (01-31), and yyyy is the year. The ISO 8601 date format yyyy-mm-dd is also accepted. For example:

zip -rt 12071991 infamy foo
zip -rt 1991-12-07 infamy foo
...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.
-tt mmddyyyy, --before-date mmddyyyy Do not operate on files modified after or at the specified date, where mm is the month (00-12), dd is the day of the month (01-31), and yyyy is the year. The ISO 8601 date format yyyy-mm-ddis also accepted. For example:

zip -rtt 11301995 infamy foo
zip -rtt 1995-11-30 infamy foo
...will add all the files in foo and its subdirectories that were last modified before 30 November 1995, to the zip archive infamy.zip.
-T, --test Test the integrity of the new zip file. If the check fails, the old zip file is unchanged and (with the -m option) no input files are removed.
-TT cmd, --unzip-command cmd Use command cmd instead of 'unzip -tqq' to test an archive when the -T option is used. On Unix, to use a copy of unzip in the current directory instead of the standard system unzip, could use:

zip archive file1 file2 -T -TT "./unzip -tqq"
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).
-u, --update Replace (update) an existing entry in the zip archive only if it has been modified more recently than the version already in the zip archive. For example:

zip -u stuff *
...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.zipinto itself when you do this).

Note that the -u option with no input file arguments acts like the -f(freshen) option.
-U, --copy-entries Copy entries from one archive to another. Requires the --out option to specify a different output file than the input archive. Copy mode is the reverse of -d (delete). When delete is being used with --out, the selected entries are deleted from the archive and all other entries are copied to the new archive, while copy mode selects the files to include in the new archive. Unlike -u (update), input patterns on the command line are matched against archive entries only and not the file system files. For instance,

zip inarchive "*.c" --copy --out outarchive
...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:

zip inarchive --out outarchive
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.
-UN v, --unicode v Determine what zip should do with Unicode file names. zip 3.0, in addition to the standard file path, now includes the UTF-8 translation of the path if the entry path is not entirely 7-bit ASCII. When an entry is missing the Unicode path, zip reverts back to the standard file path. The problem with using the standard path is this path is in the local character set of the zip that created the entry, which may contain characters that are not valid in the character set being used by the unzip. When zip is reading an archive, if an entry also has a Unicode path, zip now defaults to using the Unicode path to recreate the standard path using the current local character set.

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

e escape
as in:

zip archive -sU -UN=e
...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

u UTF-8
as in

zip archive dir -r -UN=UTF8
...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.
-v, --verbose Verbose mode or print diagnostic version info.

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).
-V, --VMS-portable On VMS, save VMS file attributes. (Files are truncated at EOF.) When a -V archive is unpacked on a non-VMS system, some file types (notably Stream_LF text files and pure binary files like fixed-512) should be extracted intact. Indexed files and file types with embedded record sizes (notably variable-length record types) will probably be seen as corrupt elsewhere.
-VV, --VMS-specific On VMS, save VMS file attributes, and all allocated blocks in a file, including any data beyond EOF. Useful for moving ill-formed files among VMS systems. When a -VV archive is unpacked on a non-VMS system, almost all files will appear corrupt.
-w, --VMS-versions On VMS, append the version number of the files to the name, including multiple versions of files. Default is to use only the most recent version of a specified file.
-ww, --VMS-dot-versions On VMS, append the version number of the files to the name, including multiple versions of files, using the .nnn format. Default is to use only the most recent version of a specified file.
-ws, --wild-stop-dirs Wildcards match only at a directory level. Normally zip handles paths as strings and given the paths

/foo/bar/dir/file1.c/foo/bar/file2.c
an input pattern such as

/foo/bar/*
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.
-x files, --exclude files Explicitly exclude the specified files, as in:

zip -r foo foo -x \*.o
...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.

Also possible:

zip -r foo foo -x@exclude.lst
...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

zip -r foo foo --exclude \*.o
and

zip -r foo foo --exclude @exclude.lst
Multiple patterns can be specified, as in:

zip -r foo foo -x \*.o \*.c
If there is no space between -x and the pattern, just one value is assumed (no list):

zip -r foo foo -x\*.o
See -i for more on include and exclude.
-X, --no-extra Do not save extra file attributes (Extended Attributes on OS/2, uid/gid and file times on Unix). The zip format uses extra fields to include additional information for each entry. Some extra fields are specific to particular systems while others are applicable to all systems. Normally when zip reads entries from an existing archive, it reads the extra fields it knows, strips the rest, and adds the extra fields applicable to that system. With -X, zip strips all old fields and only includes the Unicode and Zip64 extra fields (currently these two extra fields cannot be disabled).

Negating this option, -X-, includes all the default extra fields, but also copies over any unrecognized extra fields.
-y, --symlinks For UNIX and VMS (V8.3 and later), store symbolic links as such in the zip archive, instead of compressing and storing the file referred to by the link. This option can avoid multiple copies of files being included in the archive as zip recurses the directory trees and accesses files directly and by links.
-z, --archive-comment Prompt for a multi-line comment for the entire zip archive. The comment is ended by a line containing just a period, or an end of file condition (^D on Unix, ^Z on MSDOS, OS/2, and VMS). The comment can be taken from a file:

zip -z foo < foowhat
-Z cm, --compression-method cm Set the default compression method. Currently the main methods supported by zip are store and deflate. Compression method can be set to:

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:

zip -Z bzip2 foo bar.c
The compression method can be abbreviated:

zip -Zb foo bar.c
-# Regulate the speed of compression using the specified digit #, between 0 and 9, where -0 indicates no compression (store all files), -1 indicates the fastest compression speed (less compression) and -9 indicates the slowest compression speed (optimal compression, ignores the suffix list). The default compression level is -6.

Though still being worked, the intention is this setting will control compression speed for all compression methods. Currently only deflation is controlled.
-!, --use-privileges On Windows, use privileges (if granted) to obtain all aspects of WinNT security.
-@, --names-stdin Take the list of input files from standard input. Only one file name per line.
-$, --volume-label Include the volume label for the drive holding the first file to be compressed. If you want to include only the volume label or to force a specific drive, use the drive name as first file name, as in:
zip -$ foo a: c:bar
Environment

zip uses the following environment variables:

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.

查看英文版

查看中文版

zip 示例

zip stuff *

创建存档资料.zip(假设它不存在)并以压缩的形式将当前目录中的所有文件放入其中(除非存档名已经包含一个点,.zip后缀将自动添加;这允许显式地指定其他后缀)。

zip stuff .* *

与上述命令相同,但也包括以点开头的文件(特殊目录名“.”和“.”除外)。

zip -r foo foo

将整个foo子目录压缩到一个归档文件中,邮政编码,并记录每个文件的目录名。

zip -j foo foo/*

与上面的命令相同,但与-r不同,-j选项不会记录目录的名称,只记录文件本身的名称。

zip -s 2g -r split.zip foo

创建foo目录的拆分归档文件,每个拆分不超过2GB。如果foo包含5gb的内容,并且内容未经压缩就存储在split archive中(为了简化这个示例),这将创建三个拆分:split.z01(2GB),split.z02(2GB),以及拆分.zip略高于1GB。

zip stuff *

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).

zip stuff .* *

The same as the above command, but also includes files beginning with a dot (except for the special directory names "." and "..".

zip -r foo foo

Zips the entire subdirectory foo into an archive, foo.zip, and records the name of the directory with each file.

zip -j foo foo/*

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.

zip -s 2g -r split.zip foo

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.

查看英文版

查看中文版