Archive Compression Utilities


Archive & Compression Utilities

Long before utilities such as StuffIt and Zip existedlong before the Mac existed, in fact!Unix users could group files together into archives and compress the archives to take up less disk space, which was vastly more expensive then. Unix offers several archiving and compression tools:

  • tar (short for tape archive) was originally used to combine a collection of files into a single file, which was written to tape. But you don't have to write the file to tape; you can write it to any device your Unix system knows about: disks, tapes, CD-Rs, even Terminal.

  • compress and uncompress do what you probably expect them to: compress and expand files. Text files are very compressible, sometimes 10 to 1. Files that have already been compressed such as JPEG and MPEG files and QuickTime movies, however, can actually become larger.

  • gzip is a newer set of utilities that are like compress and uncompress on steroids. gzip includes more options and offers better compression ratios.

Tips

  • You can learn more about these commands by viewing their man pages. In the Terminal window, type man tar, man compress, man uncompress, or man gzip and press to view the command's man pages.

  • It's useful to know something about these tools because you will encounter them if you download software from Internet archives.


To create an archive from an entire directory tree

Type tar [-cxtvpf] [-C directory] archive file and press . (Consult Table 2 for tar options.)

Table 2. tar Options

Option

Description

-c

Creates a new archive

-x

Extracts files from the named archive

-t

Displays a list of files and directories in the named archive

-v

Verbose mode: Tells you everything tar is doing

-p

Preserves permissions, owners, and modification dates if possible

-f

Archives files to the following filename or extracts files from the following archive name

-C

Puts extracted files in the specified location


Here are some examples using the tar command:

  • tar -cf archive.tar file1 directory1 file2 creates and then writes to the archive named archive.tar: file1, directory1 and all its contents, and file2 in that order.

  • tar -tvf old-archive.tar displays everything in the archive called old-archive.tar but does not extract anything. The t option just prints the contents of a tar archive.

  • tar -xpvf old-archive.tar exTRacts the files and directories in the archive file called old-archive.tar and puts the resulting files in the current directory. The v option reports progress and the p option preserves the ownerships and modification dates of the original files. (The tar file is unaffected and remains on the disk.)

  • tar -xpvf old-archive.tar -C /usr/local/src exTRacts the files and directories in the archive file called old-archive.tar and puts the resulting files in the directory /usr/local/src.

Tip

  • It's a standard procedure to end archive names with a .tar suffix, and you should honor this standard to keep evil spirits out of your computer.


To compress & decompress with compress & uncompress

Type compress file ... (for example, compress file.txt), and press .

Or

Type uncompress file ... (for example, uncompress file.z), and press .

Tips

  • Your original file is removed if either of the commands successfully complete the compression or decompression.

  • By convention, compressed files should have a .Z extension. The compress command will automatically append this extension to the filename.


To compress or decompress with gzip & gunzip

Type gzip file ... and press . This compresses the files, adds the .gz suffix to their names, and removes the original files.

Or

Type gunzip file ... and press . This uncompresses the files and removes the original archive.

Tips

  • The gzip command has several options. The r option, for recursive, goes into specified subdirectories and compresses or uncompresses the files. The v option, for verbose, tells the command to report its progress.

  • zcat file lists the contents of a compressed file to Terminal (or pipes the content to another command) without altering the original archive.




Visual QuickStart Guide. Mac OS X 10. 4 Tiger
Mac Os X 10.4 Tiger (Visual Quickstart Guides)
ISBN: 0321423372
EAN: 2147483647
Year: 2003
Pages: 301
Authors: Maria Langer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net