⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch19_06.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 19] 19.6 GNU tar Sampler </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:39:28Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch19_01.htm"TITLE="19. Creating and Reading Archives"><LINKREL="prev"HREF="ch19_05.htm"TITLE="19.5 Using tar to Create and Unpack Archives "><LINKREL="next"HREF="ch19_07.htm"TITLE="19.7 Extracting Files from a Compressed Archive "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch19_05.htm"TITLE="19.5 Using tar to Create and Unpack Archives "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 19.5 Using tar to Create and Unpack Archives "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 19<BR>Creating and Reading Archives</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch19_07.htm"TITLE="19.7 Extracting Files from a Compressed Archive "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 19.7 Extracting Files from a Compressed Archive "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-7952">19.6 GNU tar Sampler </A></H2><TABLECLASS="para.programreference"BORDER="1"><TR><THVALIGN="TOP"><ACLASS="programreference"HREF="examples/index.htm"TITLE="tar">tar</A><BR></TH><TDVALIGN="TOP"><ACLASS="indexterm"NAME="AUTOID-21442"></A><ACLASS="indexterm"NAME="AUTOID-21444"></A><ACLASS="indexterm"NAME="AUTOID-21446"></A><ACLASS="indexterm"NAME="AUTOID-21449"></A>GNU <EMCLASS="emphasis">tar</EM> has plenty of features; some people would say &quot;too many.&quot;I don't agree.GNU <EMCLASS="emphasis">tar</EM> has features I wish I'd had for years in more&quot;standard&quot; versions.This article lists my favorites.For a complete list, check the documentation on the CD-ROM.</TD></TR></TABLE><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">Article<ACLASS="xref"HREF="ch19_05.htm"TITLE="Using tar to Create and Unpack Archives ">19.5</A>describes how to compress an archive file you've created.If you'reusing GNU <EMCLASS="emphasis">tar</EM>, this is even easier, since <EMCLASS="emphasis">tar</EM> itself cando the compression.Simply use the <EMCLASS="emphasis">z</EM> option when writing or reading archives.For example, to make the <EMCLASS="emphasis">gzip</EM>ped tar archive <EMCLASS="emphasis">progs.tar.gz</EM>from all &quot;.c&quot; and &quot;.h&quot; files:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>tar cvzf progs.tar.gz *.c *.h</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">Compressed tape archives aren't recommendedbecause error recovery can be difficult.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-21470"></A><ACLASS="indexterm"NAME="AUTOID-21473"></A>I've made the classic mistake of<SPANCLASS="link">archiving files with their absolute pathnames (<ACLASS="linkend"HREF="ch20_10.htm"TITLE="Avoid Absolute Paths with tar ">20.10</A>)</SPAN>.GNU <EMCLASS="emphasis">tar</EM> saves you from that goof.It always stores absolute pathnames as relative paths unless you add the<EMCLASS="emphasis">--absolute-names</EM> option.</P></LI><LICLASS="listitem"><PCLASS="para">Often I want to make a tape backup of my most recent work on a bigproject, but not all the thousands of files in a directory tree.The clumsy way to do that is by using <EMCLASS="emphasis">find&nbsp;-mtime</EM> to makean include-file for the standard <EMCLASS="emphasis">tar -I</EM> option.GNU tar to the rescue: its <EMCLASS="emphasis">--after-date</EM> option lets metell it what directories to look in and how recently the files shouldhave been changed.</P></LI><LICLASS="listitem"><PCLASS="para">When I extract an archive, I may be writing into a directory thathas other files.The <EMCLASS="emphasis">--keep-old-files</EM> option tells GNU <EMCLASS="emphasis">tar</EM> not tooverwrite existing files.</P></LI></UL><PCLASS="para">One caution about GNU <EMCLASS="emphasis">tar</EM>:it creates ANSI-format <EMCLASS="emphasis">tar</EM> archives.Extracting one of these archives with the old V7 <EMCLASS="emphasis">tar</EM> can causewarning messages like &quot;tar: unexpected EOF.&quot;But, of course, GNU <EMCLASS="emphasis">tar</EM> has an option to create old-formatarchives: <EMCLASS="emphasis">--old-archive</EM>.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</SPAN>, <SPANCLASS="authorinitials">TOR</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch19_05.htm"TITLE="19.5 Using tar to Create and Unpack Archives "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 19.5 Using tar to Create and Unpack Archives "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch19_07.htm"TITLE="19.7 Extracting Files from a Compressed Archive "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 19.7 Extracting Files from a Compressed Archive "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">19.5 Using tar to Create and Unpack Archives </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">19.7 Extracting Files from a Compressed Archive </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -