tar.texi

来自「gnu tar 源码包。 tar 软件是 Unix 系统下的一个打包软件」· TEXI 代码 · 共 1,767 行 · 第 1/5 页

TEXI
1,767
字号
@command{tar} archives with tape drives.@FIXME{this is a cop out.  need to add some simple tape drive info.}@end itemize@node stylistic conventions@section Stylistic ConventionsIn the examples, @samp{$} represents a typical shell prompt.  Itprecedes lines you should type; to make this more clear, those lines areshown in @kbd{this font}, as opposed to lines which represent thecomputer's response; those lines are shown in @code{this font}, orsometimes @samp{like this}.@c When we have lines which are too long to be@c displayed in any other way, we will show them like this:@node basic tar options@section Basic @command{tar} Operations and Options@command{tar} can take a wide variety of arguments which specify and definethe actions it will have on the particular set of files or the archive.The main types of arguments to @command{tar} fall into one of two classes:operations, and options.Some arguments fall into a class called @dfn{operations}; exactly one ofthese is both allowed and required for any instance of using @command{tar};you may @emph{not} specify more than one.  People sometimes speak of@dfn{operating modes}.  You are in a particular operating mode when youhave specified the operation which specifies it; there are eightoperations in total, and thus there are eight operating modes.The other arguments fall into the class known as @dfn{options}.  You arenot required to specify any options, and you are allowed to specify morethan one at a time (depending on the way you are using @command{tar} atthat time).  Some options are used so frequently, and are so useful forhelping you type commands more carefully that they are effectively``required''.  We will discuss them in this chapter.You can write most of the @command{tar} operations and options in anyof three forms: long (mnemonic) form, short form, and old style.  Someof the operations and options have no short or ``old'' forms; however,the operations and options which we will cover in this tutorial havecorresponding abbreviations.  We will indicate those abbreviationsappropriately to get you used to seeing them.  (Note that the ``oldstyle'' option forms exist in @GNUTAR{} for compatibility with Unix@command{tar}.  In this book we present a full discussion of this wayof writing options and operations (@pxref{Old Options}), and we discussthe other two styles of writing options (@xref{Long Options}, and@pxref{Short Options}).In the examples and in the text of this tutorial, we usually use thelong forms of operations and options; but the ``short'' forms producethe same result and can make typing long @command{tar} commands easier.For example, instead of typing@smallexample@kbd{tar --create --verbose --file=afiles.tar apple angst aspic}@end smallexample@noindentyou can type@smallexample@kbd{tar -c -v -f afiles.tar apple angst aspic}@end smallexample@noindentor even@smallexample@kbd{tar -cvf afiles.tar apple angst aspic}@end smallexample@noindentFor more information on option syntax, see @ref{Advanced tar}.  Indiscussions in the text, when we name an option by its long form, wealso give the corresponding short option in parentheses.The term, ``option'', can be confusing at times, since ``operations''are often lumped in with the actual, @emph{optional} ``options'' in certaingeneral class statements.  For example, we just talked about ``short andlong forms of options and operations''.  However, experienced @command{tar}users often refer to these by shorthand terms such as, ``short and longoptions''.  This term assumes that the ``operations'' are included, also.Context will help you determine which definition of ``options'' to use.Similarly, the term ``command'' can be confusing, as it is often used intwo different ways.  People sometimes refer to @command{tar} ``commands''.A @command{tar} @dfn{command} is the entire command line of user inputwhich tells @command{tar} what to do --- including the operation, options,and any arguments (file names, pipes, other commands, etc.).  However,you will also sometimes hear the term ``the @command{tar} command''.  Whenthe word ``command'' is used specifically like this, a person is usuallyreferring to the @command{tar} @emph{operation}, not the whole line.Again, use context to figure out which of the meanings the speakerintends.@node frequent operations@section The Three Most Frequently Used OperationsHere are the three most frequently used operations (both short and longforms), as well as a brief description of their meanings.  The rest ofthis chapter will cover how to use these operations in detail.  We willpresent the rest of the operations in the next chapter.@table @option@item --create@itemx -cCreate a new @command{tar} archive.@item --list@itemx -tList the contents of an archive.@item --extract@itemx -xExtract one or more members from an archive.@end table@node Two Frequent Options@section Two Frequently Used OptionsTo understand how to run @command{tar} in the three operating modes listedpreviously, you also need to understand how to use two of the options to@command{tar}: @option{--file} (which takes an archive file as an argument)and @option{--verbose}.  (You are usually not @emph{required} to specifyeither of these options when you run @command{tar}, but they can be veryuseful in making things more clear and helping you avoid errors.)@menu* file tutorial::* verbose tutorial::* help tutorial::@end menu@node file tutorial@unnumberedsubsec The @option{--file} Option@table @option@xopindex{file, tutorial}@item --file=@var{archive-name}@itemx -f @var{archive-name}Specify the name of an archive file.@end tableYou can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever youuse @command{tar}; this option determines the name of the archive filethat @command{tar} will work on.@vrindex TAPEIf you don't specify this argument, then @command{tar} will examinethe environment variable @env{TAPE}.  If it is set, its value will beused as the archive name.  Otherwise, @command{tar} will use thedefault archive, determined at the compile time. Usually it isstandard output or some physical tape drive attached to your machine(you can verify what the default is by running @kbd{tar--show-defaults}, @pxref{defaults}).  If there is no tape driveattached, or the default is not meaningful, then @command{tar} willprint an error message.  The error message might look roughly like oneof the following:@smallexampletar: can't open /dev/rmt8 : No such device or addresstar: can't open /dev/rsmt0 : I/O error@end smallexample@noindentTo avoid confusion, we recommend that you always specify an archive filename by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see@ref{file}.@node verbose tutorial@unnumberedsubsec The @option{--verbose} Option@table @option@xopindex{verbose, introduced}@item --verbose@itemx -vShow the files being worked on as @command{tar} is running.@end table@option{--verbose} (@option{-v}) shows details about the results of running@command{tar}.  This can be especially useful when the results might not beobvious.  For example, if you want to see the progress of @command{tar} asit writes files into the archive, you can use the @option{--verbose}option.  In the beginning, you may find it useful to use@option{--verbose} at all times; when you are more accustomed to@command{tar}, you will likely want to use it at certain times but not atothers.  We will use @option{--verbose} at times to help make somethingclear, and we will give many examples both using and not using@option{--verbose} to show the differences.Each instance of @option{--verbose} on the command line increases theverbosity level by one, so if you need more details on the output,specify it twice.When reading archives (@option{--list}, @option{--extract},@option{--diff}), @command{tar} by default prints only the names ofthe members being extracted.  Using @option{--verbose} will show a full,@command{ls} style member listing.In contrast, when writing archives (@option{--create}, @option{--append},@option{--update}), @command{tar} does not print file names bydefault.  So, a single @option{--verbose} option shows the file namesbeing added to the archive, while two @option{--verbose} optionsenable the full listing.For example, to create an archive in verbose mode:@smallexample$ @kbd{tar -cvf afiles.tar apple angst aspic}appleangstaspic@end smallexample@noindentCreating the same archive with the verbosity level 2 could give:@smallexample$ @kbd{tar -cvvf afiles.tar apple angst aspic}-rw-r--r-- gray/staff    62373 2006-06-09 12:06 apple-rw-r--r-- gray/staff    11481 2006-06-09 12:06 angst-rw-r--r-- gray/staff    23152 2006-06-09 12:06 aspic@end smallexample@noindentThis works equally well using short or long forms of options.  Usinglong forms, you would simply write out the mnemonic form of the optiontwice, like this:@smallexample$ @kbd{tar --create --verbose --verbose @dots{}}@end smallexample@noindentNote that you must double the hyphens properly each time.Later in the tutorial, we will give examples using @w{@option{--verbose--verbose}}.@anchor{verbose member listing}The full output consists of six fields:@itemize @bullet@item File type and permissions in symbolic form.These are displayed in the same format as the first column of@command{ls -l} output (@pxref{What information is listed,format=verbose, Verbose listing, fileutils, GNU file utilities}).@item Owner name and group separated by a slash character.If these data are not available (for example, when listing a @samp{v7} formatarchive), numeric @acronym{ID} values are printed instead.@item Size of the file, in bytes.@item File modification date in ISO 8601 format.@item File modification time.@item File name.If the name contains any special characters (white space, newlines,etc.) these are displayed in an unambiguous form using so called@dfn{quoting style}.  For the detailed discussion of available stylesand on how to use them, see @ref{quoting styles}.Depending on the file type, the name can be followed by someadditional information, described in the following table:@table @samp@item -> @var{link-name}The file or archive member is a @dfn{symbolic link} and@var{link-name} is the name of file it links to.@item link to @var{link-name}The file or archive member is a @dfn{hard link} and @var{link-name} isthe name of file it links to.@item --Long Link--The archive member is an old GNU format long link.  You will normallynot encounter this.@item --Long Name--The archive member is an old GNU format long name.  You will normallynot encounter this.@item --Volume Header--The archive member is a GNU @dfn{volume header} (@pxref{Tape Files}).@item --Continued at byte @var{n}--Encountered only at the beginning of a multi-volume archive(@pxref{Using Multiple Tapes}).  This archive member is a continuationfrom the previous volume. The number @var{n} gives the offset wherethe original file was split.@item  unknown file type @var{c}An archive member of unknown type. @var{c} is the type character fromthe archive header.  If you encounter such a message, it means thateither your archive contains proprietary member types @GNUTAR{} is notable to handle, or the archive is corrupted.@end table@end itemizeFor example, here is an archive listing containing most of the specialsuffixes explained above:@smallexample@groupV--------- 0/0          1536 2006-06-09 13:07 MyVolume--Volume Header---rw-r--r-- gray/staff 456783 2006-06-09 12:06 aspic--Continued atbyte 32456---rw-r--r-- gray/staff  62373 2006-06-09 12:06 applelrwxrwxrwx gray/staff      0 2006-06-09 13:01 angst -> apple-rw-r--r-- gray/staff  35793 2006-06-09 12:06 blueshrw-r--r-- gray/staff      0 2006-06-09 12:06 music link to blues@end group@end smallexample@smallexample@end smallexample@node help tutorial@unnumberedsubsec Getting Help: Using the @option{--help} Option@table @option@opindex help@item --helpThe @option{--help} option to @command{tar} prints out a very brief list ofall operations and option available for the current version of@command{tar} available on your system.@end table@node create@section How to Create Archives@UNREVISED@cindex Creation of the archive@cindex Archive, creation ofOne of the basic operations of @command{tar} is @option{--create} (@option{-c}), whichyou use to create a @command{tar} archive.  We will explain@option{--create} first because, in order to learn about the otheroperations, you will find it useful to have an archive available topractice on.To make this easier, in this section you will first create a directorycontaining three files.  Then, we will show you how to create an@emph{archive} (inside the new directory).  Both the directory, andthe archive are specifically for you to practice on.  The rest of thischapter and the next chapter will show many examples using thisdirectory and the files you will create: some of those files may beother directories and other archives.The three files you will archive in this example are called@file{blues}, @file{folk}, and @file{jazz}.  The archive is called

⌨️ 快捷键说明

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