Category Image zip/unzip/gzip/gunzip command usage


zip/unzip, gzip/gunzip and many similar utilities are built into OS X. There is no man page, but basic usage is easy....

zip, unzip
While there is no man page, the utility has built-in help...

$ zip -help
Copyright (C) 1990-1996 Mark Adler, Richard B. Wales, Jean-loup Gailly
Onno van der Linden and Kai Uwe Rommel. Type 'zip -L' for the software License.
Zip 2.1 (April 27th 1996). Usage:
zip [-options] [-b path] [-t mmddyy] [-n suffixes] [zipfile list] [-xi list]
The default action is to add or replace zipfile entries from list, which
can include the special name - to compress standard input.
If zipfile and list are omitted, zip compresses stdin to stdout.
-f freshen: only changed files -u update: only changed or new files
-d delete entries in zipfile -m move into zipfile (delete files)
-k force MSDOS (8+3) file names -g allow growing existing zipfile
-r recurse into directories -j junk (don't record) directory names
-0 store only -l convert LF to CR LF (-ll CR LF to LF)
-1 compress faster -9 compress better
-q quiet operation -v verbose operation/print version info
-c add one-line comments -z add zipfile comment
-b use "path" for temp file -t only do files after "mmddyy"
-@ read names from stdin -o make zipfile as old as latest entry
-x exclude the following names -i include only the following names
-F fix zipfile (-FF try harder) -D do not add directory entries
-A adjust self-extracting exe -J junk zip file prefix (unzipsfx)
-T test zipfile integrity -X eXclude eXtra file attributes
-y store symbolic links as the link instead of the referenced file
-h show this help -n don't compress these suffixes

To make a compressed copy of origfile.txt into a zip archive named compressedfile.zip ....
$ zip compressedfile.zip origfile.txt
Note the original file will be preserved

To uncompress a zip archive named compressedfile.zip into the current working directory
$ unzip compressedfile.zip

To zip a directory named mydir into mycompresseddir.zip
$ zip mycompresseddir.zip mydir/*

Be aware that zip has filesize limitations ..... probably 2GB ..... I just know that a 6.7GB text file won't work!

gzip, gunzip
These great little utilities are real easy

To compress a file named myfile.txt to myfile.txt.gz and automatically delete the original uncompressed version, simply type
$ gzip myfile.txt

To compress a file named myfile2.txt to myfile2.txt.gz and preserve the original, simply type
$ gzip -c myfile2.txt > myfile2.txt.gz

To inflate it back to the original file, just type
$ gunzip myfile.txt.gz

Posted: Friday - February 17, 2006 at 05:55 AM        


Published by