89 lines
4.2 KiB
HTML
89 lines
4.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
|
<!Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
|
<HEAD>
|
|
<TITLE>4.5.3 Putting them together</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value="4.5.3 Putting them together">
|
|
<meta name="keywords" value="gs">
|
|
<meta name="resource-type" value="document">
|
|
<meta name="distribution" value="global">
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html3996 HREF="node176.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3994 HREF="node172.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3990 HREF="node174.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3998 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3999 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html3997 HREF="node176.html">4.6 Using Floppies and </A>
|
|
<B>Up:</B> <A NAME=tex2html3995 HREF="node172.html">4.5 Archiving and Compressing </A>
|
|
<B> Previous:</B> <A NAME=tex2html3991 HREF="node174.html">4.5.2 gzip and compress</A>
|
|
<BR> <HR> <P>
|
|
<H2><A NAME=SECTION00653000000000000000>4.5.3 Putting them together</A></H2>
|
|
<P>
|
|
Therefore, to archive a group of files and compress the result,
|
|
you can use the commands:
|
|
<P><TT> # <em>tar cvf backup.tar /etc</em> <BR>
|
|
# <em>gzip -9 backup.tar</em>
|
|
<P></TT>
|
|
The result will be <tt>backup.tar.gz</tt>. To unpack this file, use
|
|
the reverse set of commands:
|
|
<P><TT> # <em>gunzip backup.tar.gz</em> <BR>
|
|
# <em>tar xvf backup.tar</em>
|
|
<P></TT>
|
|
Of course always make sure that you are in the correct directory
|
|
before unpacking a tar file.
|
|
<P>
|
|
You can use some UNIX cleverness to do all of this on one command
|
|
line, as in the following:
|
|
<P><TT> # <em>tar cvf - /etc <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img261.gif"> gzip -9c <b>></b> backup.tar.gz</em>
|
|
<P></TT>
|
|
Here, we are sending the tar file to ``<tt>-</tt>'', which stands for
|
|
<tt>tar</tt>'s standard output. This is piped to <tt>gzip</tt>, which
|
|
compresses the incoming tar file, and the result is saved in
|
|
<tt>backup.tar.gz</tt>.
|
|
The <tt>-c</tt> option to <tt>gzip</tt> tells <tt>gzip</tt> to send its output to
|
|
stdout, which is redirected to <tt>backup.tar.gz</tt>.
|
|
<P>
|
|
A single command used to unpack this archive would be:
|
|
<P><TT> # <em>gunzip -c backup.tar.gz <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img262.gif"> tar xvf -</em>
|
|
<P></TT>
|
|
Again, <tt>gunzip</tt> uncompresses the contents of <tt>backup.tar.gz</tt>
|
|
and sends the resulting tar file to stdout. This is piped to
|
|
<tt>tar</tt>, which reads ``<tt>-</tt>'', this time referring to <tt>tar</tt>'s
|
|
standard input.
|
|
<P>
|
|
Happily, the <tt>tar</tt> command also includes the <tt>z</tt> option to
|
|
automatically compress/uncompress files on the fly, using the
|
|
<tt>gzip</tt> compression algorithm.
|
|
<P>
|
|
For example, the command
|
|
<P><TT> # <em>tar cvfz backup.tar.gz /etc</em>
|
|
<P></TT>
|
|
is equivalent to
|
|
<P><TT> # <em>tar cvf backup.tar /etc</em> <BR>
|
|
# <em>gzip backup.tar</em>
|
|
<P></TT>
|
|
Just as the command
|
|
<P><TT> # <em>tar xvfz backup.tar.Z</em>
|
|
<P></TT>
|
|
may be used instead of
|
|
<P><TT> # <em>uncompress backup.tar.Z</em> <BR>
|
|
# <em>tar xvf backup.tar</em>
|
|
<P></TT>
|
|
<P>
|
|
Refer to the man pages for <tt>tar</tt> and <tt>gzip</tt> for more
|
|
information.
|
|
<P>
|
|
<A NAME=4660> </A>
|
|
<A NAME=4661> </A>
|
|
<A NAME=4662> </A>
|
|
<A NAME=4663> </A>
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html3996 HREF="node176.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html3994 HREF="node172.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html3990 HREF="node174.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html3998 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html3999 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html3997 HREF="node176.html">4.6 Using Floppies and </A>
|
|
<B>Up:</B> <A NAME=tex2html3995 HREF="node172.html">4.5 Archiving and Compressing </A>
|
|
<B> Previous:</B> <A NAME=tex2html3991 HREF="node174.html">4.5.2 gzip and compress</A>
|
|
<BR> <HR> <P>
|
|
<BR> <HR>
|
|
<P><ADDRESS>
|
|
<I>Matt Welsh <BR>
|
|
mdw@sunsite.unc.edu</I>
|
|
</ADDRESS>
|
|
</BODY>
|