Decompressing and Decoding Files
Eventually you will come across files that have been compressed or encoded
in some way. Compression, just as you might think, makes a file smaller
so that it may be transmitted more quickly (there's less to transmit).
Encoding changes the form of a file, usually so it can be transmitted as
email.
Below are instructions on how to undo some of the more popular compression
and encoding schemes. All of the commands below assume you're in your Unity
account.
Files compressed with Stuffit (end with .sit) and CompactPro (end with
.cpt) must be dealt with on a Macintosh or Intel-compatible machine; there
are no tools to handle these on Unity.
You should be aware of three things:
- Compressed and encoded files are usually identified by their extensions,
the character code following the file name. Depending on how they were
compressed, some files won't decompress or decode if the extension is
removed. Here are some common extensions for compressed and encoded files:
Compressed files
- filename.Z (a compressed file)
- filename.gz (a GNU compressed file)
- filename.z (a GNU compressed file -- note lowercase 'z')
- filename.zip (a zipped archive)
- filename.tar (a tarred file)
- filename.tar.Z (a file both tarred and compressed)
- filename.tar.gz (a file both tarred and GNU compressed)
- filename.tgz (abbreviated form of tarred and GNU compressed)
- filename.bz (a file compressed with bzip)
- filename.bz2 (a file compressed with bzip2)
Encoded files
- filename.uu (a uuencoded file)
- filename.hqx (a binhexed file)
- The names of compressed and encoded files may change when the files
are decompressed or decoded. For example, the file "test.uu" could be
called "first_test.txt" after it's decoded. Likewise, file.Z would become
file. You may need to look carefully at your directory listing to find
the new file.
- Decompressing or decoding a file creates a new file or files, but it
doesn't necessarily remove the original compressed or encoded file. You
usually have to remove the original when you're finished with it.
Decompressing files with .Z endings
To decompress a file with the extension .Z (uppercase), enter the command
compress -d filename.Z
The decompressed file will appear in your directory listing, and the original
.Z file will be removed.
Warning: If you run out of available disk space during
the decompression, you'll lose both the decompressed file and the compressed
file. The gunzip command below can "safely" decompress
a .Z file.
Decompressing files with .gz or .z endings
For a file with the extension .gz or .z (lowercase 'z' only), decompress
the file by using the command
gunzip filename.gz
The decompressed file will appear in your directory listing, and the
original .gz or .z file will be removed.
Decompressing files with .bz or .bz2 endings
For a file with the extension .bz or .bz2, you must first gain access
to the bzip and/or bzip2 commands by typing:
add zutils
Then, if the file ends in .bz, you uncompress it by using the command:
bzip -d filename.bz
or, if the file ends in .bz2, you uncompress it by using the command:
bzip2 -d filename.bz2
The decompressed file will appear in your directory listing, and the .bz
or .bz2 will be removed.
Decompressing files with .zip endings
To unzip the file, use the command
unzip filename.zip
These .zip files tend to produce more than one file when uncompressed.
Decompressing files with .tar endings
A file with the .tar extension contains a number of other files and even
directories compressed (tar-ed) together. TAR stands for "tape archive" and
is used primarily with tape drives.
To decompress a .tar file, type
tar -xvf filename.tar
The decompressed file will appear in your directory listing, but the original
.tar file will not be removed.
Because a .tar file may contain a large number of files and directories,
it's usually a good idea to place it in its own directory before you decompress
it. This keeps all the component files in one place and avoids confusion
with other files.
To see what's inside a .tar file without decompressing it, enter
tar -tf filename.tar
Decompressing files with more than one extension
You may come across a file such as
filename.tar.Z
First you must use the decompression utility appropriate for the last
extension. Then use the decompression utility for the first extension.
For example, to decompress the file "filename.tar.Z", you must first use
the command
compress -d filename.tar.Z
and then the command
tar -xvf filename.tar
Decoding
Decoding files with .uu endings
Binary files (graphics and programs) can't be sent through Unix email
systems as binaries and must first be converted to text-based forms. This
conversion, called "uuencoding," is not compression; in fact, uuencoded
files actually get larger.
To decode a .uu file, enter
uudecode filename.uu
Note that because uuencoding is so common, many people don't even bother
to include the ".uu" file extension. If you look at a file using the more command,
and you see characters such as
begin 644 einstein.jpg M_]C_X``02D9)1@`!`0```0`!``#_VP!#``@&!@TG!0@'!P!)"0@*#!0-#`L+
M#!D2$P\4'1H?'AT:'!P@)"XG("(L(QP!*#!I+#`Q-#0T'R!Y/3@R/"XS-#+E
the file is a uuencoded binary file, and you should use the uudecode command
to convert it to its binary form.
Converting files with .hqx endings to MacBinary format
Moving Macintosh files around the Internet requires that they be converted
to a form called binhex that Unix machines can understand and transmit.
As with uuencoded files, binhexed files actually get larger, but
you'll be able to send them through email.
MacBinary is a special format used to store and transmit Macintosh files
that are composed of many pieces. The resource fork of the Macbinary file
holds the icon and file type information, and the data fork stores almost
everything else. To gain access to the mcvert program
that both unbinhexes a binhexed file and converts it to a MacBinary file,
enter
add macutils
followed by the command
mcvert -x filename.hqx
Note: There is an Intel-based binhex format that performs
the same function on Intel-compatible computers. Currently there are no
programs in Unity that convert binhexed files to Intel-based binary
format.
Content last updated May, 20004, by daniel
Page last modified
October 19, 2005
by cawalker
|