Specifications

Compressing and Uncompressing File Archives
Mac OS X and Mac OS X Server use the GNU tar utility to compress and uncompress
les and folders. When sending folders and multiple les between computers, it's
helpful to compress them into a single archive. This saves space, allows you to transfer
just one item instead of many, and makes it easier to resume in case the task is
suspended for some reason.
The tar utility has many options, but for a basic compression of a folder named
“LotsOfFiles,” you could simply enter:
tar -czf LotsOfFiles.tgz LotsOfFiles
If its a large folder, you may want to monitor the process by adding the ‘v ag:
tar -czvf LotsOfFiles.tgz LotsOfFiles
To open an archive, use the ‘x ag. The ‘v ag is useful to watch what’s going on:
tar -xzvf LotsOfFiles.tgz
The ‘z ag indicates that the archive is being compressed, as well as being combined
into one le. Usually you’ll use this option, but you aren’t required to. The traditional
le extension for a compressed archive is .tgz, although you might also see les
ending in .tar.gz. If the archive isn’t compressed, it usually just ends in .tar.
Files created with tar can be opened in the Finder by double-clicking them. Also, if
you use the File > Compress menu command in the Finder to compress a folder or le,
the tar le can be opened using tar from the command line.
For more information about the tar command, see its man page.
Viewing File Contents
If you want to look at the contents of a text-based conguration le, you can use cat
or less. Generally, you’ll use less because it has more options (like searching).
To use less, type the command name followed by the name of the le you want to
view. The rst page of text lls the window. To view the next page, press the Space bar.
less also lets you search in a le. Type ‘/’ followed by the phrase you’re searching for. If
the phrase has spaces in it, precede each space with ‘\’:
/I\ read\ the\ other\ day
The following table lists some other useful keys for navigating the output from less.
40 Chapter 5 Common Command-Line Tasks