Java Reference
In-Depth Information
•
c
: Create an archive.
•
x
: Extract from an archive.
•
t
: Get a table of contents.
In addition, you'll want to know these options:
•
f
: The next parameter is the filename of the archive.
•
v
: Provide more verbose output.
Using these options, Table 1.4 shows examples of each of the basic
functions.
Now let's do the same thing using the
zip
command (Table 1.5). There
are actually two commands here—one to compress the files into an archive
(
zip
), and the other to reverse the process (
unzip
).
Table 1.4
Examples of the
tar
command
Command
Explanation
tar tvf packedup.tar
Gives a table of contents, in long (or verbose) form.
Without the
v
, all you get is the filenames; with the
v
you get additional information similar in format to the
ls -l
command.
tar xvf packedup.tar
Extracts all the files from the TAR file, creating them
according to their specified pathname, assuming your
user ID and file permissions allow it. Remove the
v
option if you don't want to see each filename as the file
is extracted.
tar cvf packedup.tar mydir
Creates a TAR archive named
packedup.tar
from
the
mydir
directory and its contents. Remove the
v
option if you don't want to see each filename as the file
is added to the archive.
letter options. Newer POSIX versions of UNIX and the GNU tools, which means all flavors
of Linux, also support longer full-word options prefixed with a double minus, as in
--extract
instead of
x
or
-x
.