|This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.|
Archive and package files to a gzip or pkzip format
|The zip utility compresses several files into a single archive file.|
zip [-cDdFfghiJjLlmNnqRrsTuvXx019] [-b path] [-n suffixes] [-t mmddyyyy] [-tt mmddyyyy] [zipfile [ file1 file2 ...]] [-xi list]
All supported hosts.
- -b path
- Use the specified path for the temporary zip archive.
- Add one-line comments for each file. File operations (adding, updating) are done first, and then the utility prompts for one-line comments for each file.
- Don't create entries in the zip file for directories. Directory entries are created by default to allow their attributes to be saved in the zip archive.
- Delete entries from a zip file.
- Fix the zip file. Use this option if some portions of the file are missing.
- Freshen (replace) only the files that have changed.
- Grow (append to) the specified zip file instead of creating a new one.
- Display a help message.
- Include only specified files. For example:
zip -r foo . -i \*.cThis command includes only the files that end in .c in the current directory and its subdirectories.
- Strip any prepended data (i.e. a SFX stub) from the file.
- Junk the path to the file; store just the name of the saved file.
- Display the zip license.
- Convert the UNIX end-of-line character LF to the MS-DOS convention, CR LF.
Use -ll to convert the CR LF convention back to the end-of-line character, LF.
Don't use these options on binary files.
- Move the specified files into the zip file and delete the target directories/files.
- Save filenotes as zipfile comments.
- -n suffixes
- Don't attempt to compress files named with the suffixes indicated. You can use either colons or semicolons to separate the suffixes.
- Set the "last modified" time on the zip file to match the "last modified" time on the zip archive entries.
- Change to quiet mode by eliminating informational messages and command prompts.
- Recurse into the directories starting at the current directory.
- Recurse into the directories.
- Test the integrity of the new zip file.
- -t mmddyyyy
- Don't operate on files modified prior to the specified date, where mm is the month, dd represents the day of the month, and yyyy is the year.
- -tt mmddyyyy
- Don't operate on files modified after or at the specified date, where mm is the month, dd represents the day of the month, and yyyy is the year.
- Update only changed or new files.
- Verbose mode.
- Don't save extra file attributes.
- -x files
- Explicitly exclude the files specified. For example:
zip -r foo foo -x \*.oincludes the contents of foo in foo.zip, while it excludes all the files that end in .o.
- Add a comment to the zip file.
- -0 to -9
- Regulate the speed of compression, where -0 indicates no compression, -1 (the number one) indicates the fastest compression method (less compression) and -9 indicates the slowest compression method (optimal compression). The default compression level is -6.
The zip utility is a compression and file-packaging utility. A companion program (unzip), unpacks zip archives. The zip and unzip programs can work with archives produced by PKZIP; PKZIP and PKUNZIP can work with archives produced by the zip utility.
The zip utility 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.
This utility puts one or more compressed files into a single zip archive, along with information about the files, such as name, path, date, time of last modification, protection, and check information to verify file integrity.
You can use a single command to pack an entire directory structure into a zip archive. Compression ratios of 2:1 to 3:1 are common for text files. The zip utility has one compression method (deflation) and can also store files without compression; zip automatically chooses the better of the two for each file to be compressed.
When zip is given the name of an existing zip archive, it replaces identically named entries in the archive or adds 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 foo
replaces foo/file1 in foo.zip and adds foo/file3 to foo.zip. Then, foo.zip contains foo/file1, foo/file2, and foo/file3; foo/file2 remains unchanged.
Create an archive called stuff.zip, for example, and put all the files in the current directory in it, in compressed form:
zip stuff *
The .zip suffix is added automatically, unless the archive name given contains a dot already; this allows the explicit specification of other suffixes.
Because of filename substitution, files starting with "." are not included; to include these to the file:
zip stuff .* *
|This command doesn't include any subdirectories from the current directory.|
Zip up an entire directory:
zip -r foo foo
This command creates the archive foo.zip, containing all the files and directories in the directory foo that are contained within the current directory.
You may want to make a zip archive that contains the files in foo, without recording the directory name foo. Use the -j option to leave off the paths:
zip -j foo foo/*
If you're short on disk space, you might not have enough room to hold both the original directory and the corresponding compressed zip archive. In this case, you can create the archive in steps using the -m option.
For example, if foo contains the subdirectories tom, dick, and harry, you can perform these commands:
zip -rm foo foo/tom zip -rm foo foo/dick zip -rm foo foo/harry
to create a directory called foo.zip. The first command creates the foo.zip directory, and the next two commands add to it. As each zip command completes, the last created archive is deleted, making room for the next zip command to function.
- A set of default
options for zip. For example:
- The operation succeeded.
- An error occurred; the operation failed.
- A generic error in the zipfile format was detected, but processing may have completed successfully anyway; a warning was generated in the process.
- zip was unable to allocate memory for one or more buffers during program initialization.
- A severe error in the zipfile format was detected; processing probably failed immediately.
- Entry too large to be split with zipsplit.
- Invalid comment format.
- zip -T failed or out of memory.
- The user aborted zip prematurely with Ctrl-C or a similar command.
- zip encountered an error while using a temporary file.
- Read or seek error.
- zip has nothing to do.
- Missing or empty zip file.
- Error writing to a file.
- zip was unable to create a file to write to.
- Bad command-line parameters.
- zip could not open a specified file to read.
Backing Up and Recovering Data in the Neutrino User's Guide