📄 tar.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>tar</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_2220"> </a>NAME</h4><blockquote>tar - file archiver (<b><a href="intro.html#tag_001_003_003">LEGACY</a></b>)</blockquote><h4><a name = "tag_001_014_2221"> </a>SYNOPSIS</h4><blockquote><pre><code>tar <i>key </i><b>[</b><i>file</i>...<b>]</b></code></pre></blockquote><h4><a name = "tag_001_014_2222"> </a>DESCRIPTION</h4><blockquote>The<i>tar</i>utilityprocesses archives of files.Its actions are controlled by the<i>key</i>operand.</blockquote><h4><a name = "tag_001_014_2223"> </a>OPTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_2224"> </a>OPERANDS</h4><blockquote>The following operands are supported:<dl compact><dt><i>key</i><dd>The<i>key</i>operand consists of a function letter followed immediatelyby zero or more modifying letters.The function letter is one of the following:<dl compact><dt><b>r</b><dd>Write the named<i>file</i>or fileson the end of the archive.If the archive is on a magnetic tape device,the results are unspecified.<dt><b>x</b><dd>Extract the named<i>file</i>or filesfrom the archive.If a named file matches a directory whose contentshad been written onto the archive,this directory is (recursively) extracted.If a named file in the archive does not exist on the system,the file is created with the same mode asthe one in the archive, except that theset-user-ID and set-group-ID modes are not setunless the user has appropriate privileges.If the files exist, their modes are not changed except asdescribed above.The owner, group, and modification time are restored (if possible).If no<i>file</i>operand is given, the entire content of the archive is extracted.Note that if several files with the same nameare in the archive, the last one overwrites all earlier ones.<dt><b>t</b><dd>Write to standard output the names of all the files in the archive.<dt><b>u</b><dd>Add the named<i>file</i>or filesto the archive if they are not already there, or havebeen modified since last written into the archive.If the archive is on a magnetic tape device,the results are unspecified.<dt><b>c</b><dd>Create a new archive; writing begins at the beginningof the archive, instead of after the last file.</dl><p>The following characters can beappended to the function letter.Appending the same character more than onceproduces undefined results.The order of thebandfcharacters is significant.<p><dl compact><dt><b>v</b><dd>(Verbose.)Write to standard error the name of each file processed,preceded by a string indicating the operation being performed,as follows:<table bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Key Letter</b><th align=center><b>String</b><tr valign=top><td align=center>c, r, u<td align=center>"a "<tr valign=top><td align=center>x<td align=center>"x "</table>The filename may be followed by additionalinformation, such as the size of the filein the archive or file system, in an unspecified format.When used with thetfunction letter,vwrites to standard output more information about thearchive entries than just the name.<dt><b>w</b><dd>Write the action to be taken,followed by the name of the file, and thenwait for the user's confirmation.If an affirmative response is given, the action is performed.Any other input suppresses the action.<dt><b>f</b><dd>Use the first<i>file</i>operand (or the second, ifbhas already been specified)as the name of the archive insteadof the system-dependent default.If the name of the file is -,<i>tar</i>writes to the standard output or readsfrom the standard input, whichever is appropriate.Thus,<i>tar</i>can be used as the head or tail of a pipeline.The<i>tar</i>utilitycan also be used to move directoryhierarchies with the command:<pre><code>(cd fromdir; tar cf - . ) | (cd todir; tar xf -)</code></pre><dt><b>b</b><dd>Use the first<i>file</i>operand (or the second, iffhas already been specified)as the blocking factor for tape records.The default is not greater than 20; the maximum is not less than 20.This modifiershould only be used with raw magnetic tape archives (seefabove).The block size is determined automatically when readingtapes (function lettersxandt).<dt><b>l</b><dd>Report if all of the linksto the files being archived cannot be resolved.Iflis not specified, no error messages are written.<dt><b>m</b><dd>Do not restore the modification times.The modification time of the filewill be the time of extraction.<dt><b>o</b><dd>Assign to extracted filesthe user and group identifier ofthe user running the programrather than those on the archive.</dl><p><dt><i>file</i><dd>A pathname of a regular file or directory to be archived(when thec,rorufunction letters are used),extracted (<i>x</i> )or listed (<i>t</i> ).When<i>file</i>is the pathname of a directory, the action applies toall of the files and (recursively) subdirectories of that directory.When either or both of theborfletters are used in the<i>key</i>operand, the initial<i>file</i>operands are interpreted as a blocking factor or archive name,as described previously.<p></dl></blockquote><h4><a name = "tag_001_014_2225"> </a>STDIN</h4><blockquote>When thefmodifier is used with thetorxfunction letter and the pathname is -, the standard inputis an archive file formatted as specified by<i><a href="pax.html">pax</a></i>with the<b>-x ustar</b>option.Otherwise, the standard input is not used.</blockquote><h4><a name = "tag_001_014_2226"> </a>INPUT FILES</h4><blockquote>The files identified by the<i>file</i>operands are regular files or directories.</blockquote><h4><a name = "tag_001_014_2227"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables may affect the execution of<i>tar</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_COLLATE</i><dd>Determine the locale for thebehaviour of ranges, equivalence classesand multi-character collating elementsused in the extended regular expression defined for the<b>yesexpr</b>locale keyword in the LC_MESSAGES category.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments and input files)and the behaviour of character classesused in the extended regular expression defined for the<b>yesexpr</b>locale keyword in the LC_MESSAGES category.<dt><i>LC_MESSAGES</i><dd>Determine the locale for the processing of affirmative responsesand that should be used to affectthe format and contents of diagnosticmessages written to standard error.<dt><i>LC_TIME</i><dd>Determine the format of date and time strings output whenlisting the contents of an archive with thevmodifier; for example:<pre><code>tar tvf /dev/tape</code></pre><dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i><dt><i>TZ</i><dd>Determine the timezone used with date and time strings.</dl></blockquote><h4><a name = "tag_001_014_2228"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_2229"> </a>STDOUT</h4><blockquote>When thefmodifier is used with ther,uorcfunction letter and the pathname is -, the standard outputis an archive file formatted as specified by<i><a href="pax.html">pax</a></i>with the<b>-x ustar</b>option.When thetfunction letter is used, the standard outputconsists of the names of the files in the archive,separated bynewline characters;ifvis used witht,the standard output includes additional informationin an unspecified format.Otherwise, the standard output is not used.</blockquote><h4><a name = "tag_001_014_2230"> </a>STDERR</h4><blockquote>The standard error isused for diagnostic messages and the filename outputdescribed under thevmodifier (when thetfunction letter is not used).</blockquote><h4><a name = "tag_001_014_2231"> </a>OUTPUT FILES</h4><blockquote>Output files are created, as specified by the archive, when thexfunction letter is used.</blockquote><h4><a name = "tag_001_014_2232"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_2233"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>Successful completion.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_2234"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_2235"> </a>APPLICATION USAGE</h4><blockquote>Some systems have usually had blocking factors in therange 1 to at least 127 with a default of 20 while othersystems have usually had blocking factors in the range 1to 20 with a default of 1.For maximum portability,applications should specify a blocking factor no larger than 20.<p>For portable communication of data between XSI-conformant systems, it isrecommended that only characters defined in theISO/IEC 646:1991 standard International Reference Version(equivalent to ASCII) 7-bit range ofcharacters be used and that only characters defined in the PortableFilename Character Set be used for naming files.This recommendationis given because XSI-conformant systems support diverse codesets and run invarious geographical areas and there is no single, well establishedcodeset that incorporates all of the characters of the languages ofthe various geographical areas.<p>Note that the<i>tar</i>format can only support files up to 8 gigabytes in size.<p>Applications should migrate to the<i><a href="pax.html">pax</a></i>utility.</blockquote><h4><a name = "tag_001_014_2236"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_2237"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_2238"> </a>SEE ALSO</h4><blockquote><i><a href="cpio.html">cpio</a></i>,<i><a href="pax.html">pax</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -