|
|
1.1 root 1:
2: ZIP(1) USER COMMANDS ZIP(1)
3:
4: NAME
5: zip, zipcloak, zipnote, zipsplit - package and compress
6: (archive) files
7:
8: SYNOPSIS
9: zip [ -cdeEfghjklmoqruwyz@ ] [ -b temppath ] [ -n suffixes ]
10: [ -t mmddyy ] [ zipfile list ] [ -x list ]
11:
12: zipcloak [ -d ] [ -b path ] zipfile
13:
14: zipnote [ -w ] [ -b path ] zipfile
15:
16: zipsplit [ -ti ] [ -n size ] [ -b path ] zipfile
17:
18: DESCRIPTION
19: zip is a compression and file packaging utility for Unix,
20: VMS, MSDOS, OS/2, Windows NT, Minix, Atari and Macintosh.
21: It is analogous to a combination of tar and compress and is
22: compatible with PKZIP (Phil Katz ZIP) for MSDOS systems.
23:
24: There is a companion to zip called unzip (of course) which
25: you should be able to find the same place you got zip. zip
26: and unzip can work with files produced by PKZIP under MSDOS,
27: and PKZIP and PKUNZIP can work with files produced by zip.
28:
29: zip version 1.9 is compatible with pkzip 1.93a. Note that
30: pkunzip 1.10 cannot extract files produced by pkzip 1.93a or
31: zip 1.9. You must use pkunzip 1.93a or unzip 5.0 to extract
32: them.
33:
34: For a brief help on zip and unzip, run each without specify-
35: ing any parameters on the command line.
36:
37: zip puts one or more compressed files into a single "zip
38: file" along with information about the files, including the
39: name, path if requested, date and time last modified, pro-
40: tection, and check information to verify the fidelity of
41: each entry. zip can also be used as a filter, compressing
42: standard input to standard output. zip can pack an entire
43: directory structure in a zip file with a single command.
44: Compression ratios of 2:1 to 3:1 are common for text files.
45: zip has one compression method (deflation) and can also
46: store files without compression. It automatically chooses
47: the better of the two for each file to be compressed.
48:
49: zip is useful for packaging a set of files to send to some-
50: one or for distribution; for archiving or backing up files;
51: and for saving disk space by temporarily compressing unused
52: files or directories.
53:
54: HOW TO USE ZIP
55: The simplest use of zip is as follows:
56:
57: zip stuff *
58:
59: This will create the file "stuff.zip" (assuming it does not
60: exist) and put all the files in the current directory in
61: stuff.zip in a compressed form. The .zip suffix is added
62: automatically, unless that file name given contains a dot
63: already. This allows specifying suffixes other than ".zip".
64:
65: Because of the way the shell does filename substitution,
66: files that start with a "." are not included. To include
67: those as well, you can:
68:
69: zip stuff .* *
70:
71: Even this will not include any subdirectories that are in
72: the current directory. To zip up an entire directory, the
73: command:
74:
75: zip -r foo foo
76:
77: will create the file "foo.zip" containing all the files and
78: directories in the directory "foo" that is in the current
79: directory. (The first "foo" denotes the zip file, the second
80: one denotes the directory.) The "r" option means recurse
81: through the directory structure. In this case, all the
82: files and directories in foo are zipped, including the ones
83: that start with a ".", since the recursion does not use the
84: shell's file-name substitution. You should not use -r with
85: the name ".*", since that matches ".." which will attempt to
86: zip up the parent directory--probably not what was intended.
87:
88: You may want to make a zip file that contains the files in
89: foo, but not record the directory name, foo. You can use
90: the -j (junk path) option to leave off the path:
91:
92: zip -j foo foo/*
93:
94: The -y option (only under Unix) will store symbolic links as
95: such in the zip file, instead of compressing and storing the
96: file referred to in the link.
97:
98: You might be zipping to save disk space, in which case you
99: could:
100:
101: zip -rm foo foo
102:
103: where the "m" option means "move". This will delete foo and
104: its contents after making foo.zip. No deletions will be
105: done until the zip has completed with no errors. This
106: option is obviously more dangerous and should be used with
107: care.
108:
109: If the zip file already exists, these commands will replace
110: existing or add new entries to the zip file. For example,
111: if you were really short on disk space, you might not have
112: enough room simultaneously to hold the directory foo and the
113: compressed foo.zip. In this case, you could do it in steps.
114: If foo contained the subdirectories tom, dick, and harry,
115: then you could:
116:
117: zip -rm foo foo/tom
118: zip -rm foo foo/dick
119: zip -rm foo foo/harry
120:
121: where the first command would create foo.zip, and the next
122: two would add to it. At the completion of each zip command,
123: the directory just zipped would be deleted, making room in
124: which the next zip command could work.
125:
126: zip will also accept a single dash ("-") as the zip file
127: name, in which case it will write the zip file to stdout,
128: allowing the output to be piped to another program. For
129: example:
130:
131: zip -r - . | dd of=/dev/nrst0 obs=16k
132:
133: would write the zip output directly to a tape with the
134: specified block size for the purpose of backing up the
135: current directory.
136:
137: zip also accepts a single dash ("-") as the name of a file
138: to be compressed, in which case it will read the zip file
139: from stdin, allowing zip to take input from another program.
140: For example:
141:
142: tar cf - . | zip backup -
143:
144: would compress the output of the tar command for the purpose
145: of backing up the current directory. This generally produces
146: better compression than the previous example using the -r
147: option, because zip can take advantage of redundancy between
148: files. The backup can be restored using the command
149:
150: unzip -p backup | tar xf -
151:
152: When no zip file name is given and stdout is not a terminal,
153: zip acts as a filter, compressing standard input to standard
154: output. For example,
155:
156: tar cf - . | zip | dd of=/dev/nrst0
157:
158: is equivalent to
159:
160: tar cf - . | zip - - | dd of=/dev/nrst0
161:
162: Zip archives created in this manner can be extracted with
163: the program funzip which is provided in the unzip package.
164: For example,
165:
166: dd if=/dev/nrst0 | funzip | tar xvf -
167:
168: MODIFYING EXISTING ZIP FILES
169: When given the name of an existing zip file with the above
170: commands, zip will replace identically named entries in the
171: zip file or add entries for new names. For example, if
172: foo.zip exists and contains foo/file1 and foo/file2, and the
173: directory foo contains the files foo/file1 and foo/file3,
174: then:
175:
176: zip -r foo foo
177:
178: will replace foo/file1 in foo.zip and add foo/file3 to
179: foo.zip. After this, foo.zip contains foo/file1, foo/file2,
180: and foo/file3, with foo/file2 unchanged from before.
181:
182: When changing an existing zip file, zip will write a tem-
183: porary file with the new contents, and only replace the old
184: one when the zip has completed with no errors. You can use
185: the -b option to specify a different path (usually a dif-
186: ferent device) to put the temporary file in. For example:
187:
188: zip -b /tmp stuff *
189:
190: will put the temporary zip file and the temporary compres-
191: sion files in the directory "/tmp", copying over stuff.zip
192: in the current directory when done.
193:
194: If you are only adding entries to a zip file, not replacing,
195: and the -g option is given, then zip grows (appends to) the
196: file instead of copying it. The danger of this is that if
197: the operation fails, the original zip file is corrupted and
198: lost.
199:
200: There are two other ways to change or add entries in a zip
201: file that are restrictions of simple addition or replace-
202: ment. The first is -u (update) which will add new entries
203: to the zip file as before but will replace existing entries
204: only if the modified date of the file is more recent than
205: the date recorded for that name in the zip file. For exam-
206: ple:
207:
208: zip -u stuff *
209:
210: will add any new files in the current directory, and update
211: any changed files in the zip file stuff.zip. Note that zip
212: will not try to pack stuff.zip into itself when you do this.
213: zip will always exclude the zip file from the files on which
214: to be operated.
215:
216: The second restriction is -f (freshen) which, like update,
217: will only replace entries with newer files; unlike update,
218: will not add files that are not already in the zip file.
219: For this option, you may want to simply freshen all of the
220: files that are in the specified zip file. To do this you
221: would simply:
222:
223: zip -f foo
224:
225: Note that the -f option with no arguments freshens all the
226: entries in the zip file. The same is true of -u, and hence
227: "zip -u foo" and "zip -f foo" both do the same thing.
228:
229: This command should be run from the same directory from
230: which the original zip command was run, since paths stored
231: in zip files are always relative.
232:
233: Another restriction that can be used with adding, updating,
234: or freshening is -t (time), which will not operate on files
235: modified earlier than the specified date. For example:
236:
237: zip -rt 120791 infamy foo
238:
239: will add all the files in foo and its subdirectories that
240: were last modified on December 7, 1991, or later to the zip
241: file infamy.zip.
242:
243: Also, files can be explicitly excluded using the -x option:
244:
245: zip -r foo foo -x \*.o
246:
247: which will zip up the contents of foo into foo.zip but
248: exclude all the files that end in ".o". Here the backslash
249: causes zip to match file names that were found when foo was
250: searched.
251:
252: The last operation is -d (delete) which will remove entries
253: from a zip file. An example might be:
254:
255: zip -d foo foo/tom/junk foo/harry/\* \*.o
256:
257: which will remove the entry foo/tom/junk, all of the files
258: that start with "foo/harry/", and all of the files that end
259: with ".o" (in any path). Note that once again, the shell
260: expansion has been inhibited with backslashes, so that zip
261: can see the asterisks. zip can then match on the contents of
262: the zip file instead of the contents of the current direc-
263: tory.
264:
265: Under MSDOS, -d is case sensitive when it matches names in
266: the zip file. This allows deleting names that were zipped
267: on other systems, but requires that the names be entered in
268: upper case if they were zipped on an MSDOS system, so that
269: the names can be found in the zip file and deleted.
270:
271: MORE OPTIONS
272: As mentioned before, zip will use the best of two methods:
273: deflate or store.
274:
275: The option -0 will force zip to use store on all files. For
276: example:
277:
278: zip -r0 foo foo
279:
280: will zip up the directory foo into foo.zip using only store.
281:
282: The speed of deflation can also be controlled with options
283: -1 (fastest method but less compression) to -9 (best
284: compression but slower). The default value is -5. For exam-
285: ple:
286:
287: zip -r8 foo foo
288:
289: In nearly all cases, a file that is already compressed can-
290: not be compressed further by zip, or if it can, the effect
291: is minimal. The -n option prevents zip from trying to
292: compress files that have the given suffixes. Such files are
293: simply stored (0% compression) in the output zip file, so
294: that zip doesn't waste its time trying to compress them.
295: The suffixes are separated by either colons or semicolons.
296: For example:
297:
298: zip -rn ".Z:.zip:.tiff:.gif:.snd" foo foo
299:
300: will put everything in foo into foo.zip, but will store any
301: files that end in .Z, .zip, .tiff, .gif, or .snd without
302: trying to compress them. (Image and sound files often have
303: their own specialized compression methods.) The default suf-
304: fix list is ".Z:.zip;.zoo:.arc:.lzh:.arj". The environment
305: variable ZIPOPT can be used to change this default. For
306: example under Unix with csh:
307:
308: setenv ZIPOPT "-n .gif:.zip"
309:
310: The variable ZIPOPT can be used for any option and can
311: include several options.
312:
313: Under Unix and under OS/2 (if files from an HPFS are
314: stored), zip will store the full path (relative to the
315: current path) and name of the file (or just the name if -j
316: is specified) in the zip file along with the Unix
317: attributes, and it will mark the entry as made under Unix.
318: If the zip file is intended for PKUNZIP under MSDOS, then
319: the -k (Katz) option should be used to attempt to convert
320: the names and paths to conform to MSDOS, store only the
321: MSDOS attribute (just the user write attribute from Unix),
322: and mark the entry as made under MSDOS (even though it
323: wasn't).
324:
325: The -o (older) option will set the "last modified" time of
326: the zip file to the latest "last modified" time of the
327: entries in the zip file. This can be used without any other
328: operations, if desired. For example:
329:
330: zip -o foo
331:
332: will change the last modified time of foo.zip to the latest
333: time of the entries in foo.zip.
334:
335: The -e and -c options operate on all files updated or added
336: to the zip file. Encryption (-e) will prompt for a password
337: on the terminal and will not echo the password as it is
338: typed (if stderr is not a TTY, zip will exit with an error).
339: New zip entries will be encrypted using that password. For
340: added peace of mind, you can use -ee, which will prompt for
341: the password twice, checking that the two are the same
342: before using it. The encryption code is distributed
343: separately, so the -e option may not be available in your
344: version.
345:
346: One-line comments can be added for each file with the -c
347: option. The zip file operations (adding or updating) will
348: be done first, and you will then be prompted for a one-line
349: comment for each file. You can then enter the comment fol-
350: lowed by return, or just return for no comment.
351:
352: The -z option will prompt you for a multi-line comment for
353: the entire zip file. This option can be used by itself, or
354: in combination with other options. The comment is ended by
355: a line containing just a period, or an end of file condition
356: (^D on Unix, ^Z on MSDOS, OS/2, and VAX/VMS). Since -z
357: reads the lines from stdin, you can simply take the comment
358: from a file:
359:
360: zip -z foo < foowhat
361:
362: The -q (quiet) option eliminates the informational messages
363: and comment prompts while zip is operating. This might be
364: used in shell scripts, for example, or if the zip operation
365: is being performed as a background task ("zip -q foo *.c
366: &").
367:
368: zip can take a list of file names to operate on from stdin
369: using the -@ option. In Unix, this option can be used with
370: the find command to extend greatly the functionality of zip.
371: For example, to zip up all the C source files in the current
372: directory and its subdirectories, you can:
373:
374: find . -type f -name "*.[ch]" -print | zip source -@
375:
376: Note that the pattern must be quoted to keep the shell from
377: expanding it.
378:
379: Under VMS only, the -w option will append the version number
380: of the files to the name and zip up multiple versions of
381: files. Without -w, zip will only use the most recent ver-
382: sion of the specified file(s).
383:
384: The -l option translates the Unix end-of-line character LF
385: into the MSDOS convention CR LF. This option should not be
386: used on binary files. This option can be used on Unix if
387: the zip file is intended for PKUNZIP under MSDOS. If the
388: input files already contain CR LF, this option adds an extra
389: CR. This ensure that "unzip -a" on Unix will get back an
390: exact copy of the original file, to undo the effect of "zip
391: -l".
392:
393: If zip is run with the -h option, or with no arguments and
394: standard output is a terminal, the license and the command-
395: argument and option help is shown. The -L option just shows
396: the license.
397:
398: ABOUT PATTERN MATCHING
399: (Note: this section applies to Unix. Watch this space for
400: details on MSDOS and VMS operation.)
401:
402: The Unix shell (sh or csh) does filename substitution on
403: command arguments. The special characters are ?, which
404: matches any single character; * which matches any number of
405: characters (including none); and [] which matches any char-
406: acter in the range inside the brackets (like [a-f] or
407: [0-9]). When these characters are encountered (and not
408: escaped with a backslash or quotes), the shell will look for
409: files relative to the current path that match the pattern,
410: and replace the argument with a list of the names that
411: matched.
412:
413: zip can do the same matching on names that are in the zip
414: file being modified or, in the case of the -x (exclude)
415: option, on the list of files to be operated on, by using
416: backslashes or quotes to tell the shell not to do the name
417: expansion. In general, when zip encounters a name in the
418: list of files to do, it first looks for the name in the file
419: system. If it finds it, it then adds it to the list of
420: files to do. If it does not find it, it will look for the
421: name in the zip file being modified (if it exists), using
422: the pattern matching characters above, if any. For each
423: match, it will add that name to the list of files to do.
424: After -x (exclude), the names are removed from the to-do
425: list instead of added.
426:
427: The pattern matching includes the path, and so patterns like
428: \*.o match names that end in ".o", no matter what the path
429: prefix is. Note that the backslash must precede every spe-
430: cial character (i.e. ?*[]), or the entire argument must be
431: enclosed in double quotes ("").
432:
433: In general, using backslash to make zip do the pattern
434: matching is used with the -f (freshen) and -d (delete)
435: options, and sometimes after the -x (exclude) option when
436: used with any operation (add, -u, -f, or -d). zip will
437: never use pattern matching to search the file system. If
438: zip has recursed into a directory, all files (and all direc-
439: tories) in there are fair game.
440:
441: COPYRIGHT
442: Copyright (C) 1990-1992 Mark Adler, Richard B. Wales, Jean-
443: loup Gailly, Kai Uwe Rommel and Igor Mandrichenko. Permis-
444: sion is granted to any individual or institution to use,
445: copy, or redistribute this software so long as all of the
446: original files are included unmodified, that it is not sold
447: for profit, and that this copyright notice is retained.
448:
449: ACKNOWLEDGEMENTS
450: Thanks to R. P. Byrne for his Shrink.Pas program which
451: inspired this project; to Phil Katz for making the zip file
452: format, compression format, and .zip filename extension all
453: public domain; to Steve Burg and Phil Katz for help on
454: unclear points of the deflate format; to Keith Petersen and
455: Rich Wales for providing a mailing list and ftp site for the
456: INFO-ZIP group to use; and most importantly, to the INFO-ZIP
457: group itself (listed in the file infozip.who) without whose
458: tireless testing and bug-fixing efforts a portable zip would
459: not have been possible. Finally we should thank (blame) the
460: INFO-ZIP moderator, David Kirschbaum for getting us into
461: this mess in the first place.
462:
463: SEE ALSO
464: unzip(1), tar(1), compress(1)
465:
466: BUGS
467: WARNING: zip files produced by zip 1.9 must not be *updated*
468: by zip 1.0 or pkzip 1.10 or pkzip 1.93a, if they contain
469: encrypted members, or if they have been produced in a pipe
470: or on a non seekable device. The old versions of zip or
471: pkzip would destroy the zip structure. The old versions can
472: list the contents of the zip file but cannot extract it any-
473: way (because of the new compression algorithm). If you do
474: not use encryption and use regular disk files, you do not
475: have to care about this problem.
476:
477: zip 1.9 is compatible with pkzip 1.93a, except when two
478: features are used: encryption or zip file created in a pipe
479: or on a non seekable device. pkzip versions above 2.0 will
480: support such files, and unzip 5.0 already supports them.
481:
482: Without -y, when zip must compress a symbolic link to an non
483: existing file, it only displays a warning "name not
484: matched". A better warnign should be given.
485:
486: The option -e also forces -o (make zipfile as old as latest
487: entry). This is used to make brute force attacks on the
488: password harder.
489:
490: Under VMS, not all of the odd file formats are treated prop-
491: erly. Only zip files of format stream-LF and fixed length
492: 512 are expected to work with zip. Others can be converted
493: using Rahul Dhesi's BILF program. This version of zip does
494: handle some of the conversion internally. When using Kermit
495: to transfer zip files from Vax to MSDOS, type "set file type
496: block" on the Vax. When transfering from MSDOS to Vax, type
497: "set file type fixed" on the Vax. In both cases, type "set
498: file type binary" on MSDOS.
499:
500: Under VMS, zip hangs for file specification that uses DECnet
501: syntax (foo::*.*).
502:
503: Under OS/2, the amount of External Attributes displayed by
504: DIR is (for compatibility) the amount returned by the 16-bit
505: version of DosQueryPathInfo(). Otherwise OS/2 1.3 and 2.0
506: would report different EA sizes when DIRing a file. How-
507: ever, the structure layout returned by the 32-bit
508: DosQueryPathInfo() is a bit different, it uses extra padding
509: bytes and link pointers (it's a linked list) to have all
510: fields on 4-byte boundaries for portability to future RISC
511: OS/2 versions. Therefore the value reported by ZIP (which
512: uses this 32-bit-mode size) differs from that reported by
513: DIR. ZIP stores the 32-bit format for portability, even the
514: 16-bit MS-C-compiled version running on OS/2 1.3, so even
515: this one shows the 32-bit-mode size.
516:
517: LIKE ANYTHING ELSE THAT'S FREE, ZIP AND ITS ASSOCIATED UTIL-
518: ITIES ARE PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY
519: KIND, EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL THE
520: COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES RESULTING FROM
521: THE USE OF THIS SOFTWARE.
522:
523: That having been said, please send any problems or comments
524: via email to the Internet address [email protected]. For
525: bug reports, please include the version of zip, the make
526: options you used to compile it, the machine and operating
527: system you are using, and as much additional information as
528: possible. Thank you for your support.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.