\input texinfo
@c %**start of header
@setfilename tar.info
@settitle GNU tar
@finalout
@c %**end of header

@c FIXME: clean the following list as the documentation is revised
@c {"absolute-names", no_argument, NULL, 'P'},
@c {"absolute-paths", no_argument, NULL, 'P'},
@c {"after-date", required_argument, NULL, 'N'},
@c {"append", no_argument, NULL, 'r'},
@c {"atime-preserve", no_argument, &flag_atime_preserve, 1},
@c {"block-compress", no_argument, &flag_compress_block, 1},
@c {"block-size", required_argument, NULL, 'b'},
@c {"catenate", no_argument, NULL, 'A'},
@c {"compare", no_argument, NULL, 'd'},
@c {"compress", no_argument, NULL, 'Z'},
@c {"concatenate", no_argument, NULL, 'A'},
@c {"create", no_argument, NULL, 'c'},
@c {"delete", no_argument, NULL, OPTION_DELETE},
@c {"diff", no_argument, NULL, 'd'},
@c {"directory", required_argument, NULL, 'C'},
@c {"exclude", required_argument, NULL, OPTION_EXCLUDE},
@c {"exclude-from", required_argument, NULL, 'X'},
@c {"extract", no_argument, NULL, 'x'},
@c {"file", required_argument, NULL, 'f'},
@c {"files-from", required_argument, NULL, 'T'},
@c {"force-local", no_argument, &flag_force_local, 1},
@c {"get", no_argument, NULL, 'x'},
@c {"gunzip", no_argument, NULL, 'z'},
@c {"gzip", no_argument, NULL, 'z'},
@c {"ignore-failed-read", no_argument, &flag_ignore_failed_read, 1},
@c {"ignore-zeros", no_argument, NULL, 'i'},
@c {"incremental", no_argument, NULL, 'G'},
@c {"info-script", required_argument, NULL, 'F'},
@c {"keep-old-files", no_argument, NULL, 'k'},
@c {"label", required_argument, NULL, 'V'},
@c {"list", no_argument, NULL, 't'},
@c {"listed-incremental", required_argument, NULL, 'g'},
@c {"modification-time", no_argument, NULL, 'm'},
@c {"multi-volume", no_argument, NULL, 'M'},
@c {"new-volume-script", required_argument, NULL, 'F'},
@c {"newer", required_argument, NULL, 'N'},
@c {"newer-mtime", required_argument, NULL, OPTION_NEWER_MTIME},
@c {"null", no_argument, NULL, OPTION_NULL},
@c {"one-file-system", no_argument, NULL, 'l'},
@c {"preserve", no_argument, NULL, OPTION_PRESERVE},
@c {"preserve-order", no_argument, NULL, 's'},
@c {"preserve-permissions", no_argument, NULL, 'p'},
@c {"read-full-blocks", no_argument, NULL, 'B'},
@c {"remove-files", no_argument, &flag_remove_files, 1},
@c {"rsh-command", required_argument, NULL, OPTION_RSH_COMMAND},
@c {"same-order", no_argument, NULL, 's'},
@c {"same-owner", no_argument, &flag_do_chown, 1},
@c {"same-permissions", no_argument, NULL, 'p'},
@c {"sparse", no_argument, NULL, 'S'},
@c {"starting-file", required_argument, NULL, 'K'},
@c {"tape-length", required_argument, NULL, 'L'},
@c {"to-stdout", no_argument, NULL, 'O'},
@c {"uncompress", no_argument, NULL, 'Z'},
@c {"ungzip", no_argument, NULL, 'z'},
@c {"update", no_argument, NULL, 'u'},
@c {"use-compress-program", required_argument, NULL, OPTION_COMPRESS_PROG},
@c {"volno-file", required_argument, NULL, OPTION_VOLNO_FILE},

@set absolute-names @samp{--absolute-names} (@samp{-P})
@set after-date @samp{--after-date=@var{date}} (@samp{-N @var{date}})
@set append @samp{--append} (@samp{-r})
@set atime-preserve @samp{--atime-preserve}
@set block-size @samp{--block-size=@var{512-size}} (@samp{-b @var{512-size}})
@set checkpoint @samp{--checkpoint}
@set concatenate @samp{--concatenate} (@samp{-A})
@set compare @samp{--compare} (@samp{-d})
@set compress @samp{--compress} (@samp{-Z})
@set compress-block @samp{--compress-blocks}
@set create @samp{--create} (@samp{-c})
@set delete @samp{--delete}
@set dereference @samp{--dereference} (@samp{-h})
@set directory @samp{--directory=@var{directory}} (@samp{-C @var{directory}})
@set exclude @samp{--exclude=@var{pattern}}
@set exclude-from @samp{--exclude-from=@var{file-of-patterns}} (@samp{-X @var{file-of-patterns}})
@set extract @samp{--extract} (@samp{-x})
@set file @samp{--file=@var{archive-name}} (@samp{-f @var{archive-name}})
@set files-from @samp{--files-from=@var{file-of-names}} (@samp{-T @var{file-of-names}})
@set force-local @samp{--force-local}
@set gzip @samp{--gzip} (@samp{-z})
@set help @samp{--help}
@set ignore-zeros @samp{--ignore-zeros} (@samp{-i})
@set incremental @samp{--incremental} (@samp{-G})
@set info-script @samp{--info-script=@var{script-name}} (@samp{-F @var{script-name}})
@set interactive @samp{--interactive} (@samp{-w})
@set keep-old-files @samp{--keep-old-files} (@samp{-k})
@set label @samp{--label=@var{archive-label}} (@samp{-V @var{archive-label}})
@set list @samp{--list} (@samp{-t})
@set listed-incremental @samp{--listed-incremental=@var{snapshot-file}} (@samp{-g @var{snapshot-file}})
@set modification-time @samp{--modification-time} (@samp{-m})
@set multi-volume @samp{--multi-volume} (@samp{-M})
@set newer-mtime @samp{--newer-mtime=@var{date}}
@set null @samp{--null}
@set old-archive @samp{--old-archive} (@samp{-o})
@set one-file-system @samp{--one-file-system} (@samp{-l})
@set preserve @samp{--preserve}
@set read-full-blocks @samp{--read-full-blocks} (@samp{-B})
@set record-number @samp{--record-number} (@samp{-R})
@set same-order @samp{--same-order} (@samp{-s})
@set same-permissions @samp{--same-permissions} (@samp{-p})
@set show-omitted-dirs @samp{--show-omitted-dirs}
@set sparse @samp{--sparse} (@samp{-S})
@set starting-file @samp{--starting-file=@var{name}} (@samp{-K @var{name}})
@set tape-length @samp{--tape-length=@var{1024-size}} (@samp{-L @var{1024-size}})
@set to-stdout @samp{--to-stdout} (@samp{-O})
@set totals @samp{--totals}
@set update @samp{--update} (@samp{-u})
@set verbose @samp{--verbose} (@samp{-v})
@set verify @samp{--verify} (@samp{-W})
@set version @samp{--version}
@set volno-file @samp{--volno-file=@var{file-of-number}}

@include version.texi

@c Put everything in one index (arbitrarily chosen to be the concept index).
@syncodeindex fn cp
@syncodeindex ky cp
@syncodeindex pg cp
@syncodeindex vr cp

@ifinfo
@set Francois Franc,ois
@end ifinfo
@tex
@set Francois Fran\noexpand\ptexc cois
@end tex

@ifinfo
@format
START-INFO-DIR-ENTRY
* tar: (tar).			Making tape (or disk) archives.
END-INFO-DIR-ENTRY
@end format
@end ifinfo

@ifinfo
This file documents GNU @code{tar}, a utility used to store, backup, and
transport files.

Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).

@end ignore
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@end ifinfo

@titlepage
@title GNU tar: an archiver tool (*DRAFT*)
@subtitle For version @value{VERSION}, @value{UPDATED}
@author Jay Fenlason, Michael Bushnell
@author Amy Gorin, @value{Francois} Pinard

@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1992, 1994, 1995 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@end titlepage

@ifinfo
@node Top, Introduction, (dir), (dir)
@top GNU tar

This file documents @code{tar}, a utility used to store, backup,
and transport files.  It is a rudimentary documentation for the GNU
tape (or disk) archiver.  It covers the release @value{VERSION}.

This document has been quickly assembled from random notes and sources.
I will of course accept documentation bug reports, but please do not
torture yourself into systematically reporting all inadequacies for
unrevised nodes.

@end ifinfo

@menu
* Introduction::                
* Tutorial::                    
* Invoking tar::                
* Basic tar Operations::        
* Specifying Names to tar::     
* Being Careful::               
* Format Control::              
* Media::                       
* Backups and Restoration::     
* Date input formats::          
* Archive Format::              
* Index::                       

 --- The Detailed Node Listing ---

Introduction

* What tar Does::               
* Authors::                     
* Bug reports::                 
* Support::                     

Support considerations

* Stability::                   
* Rewriting::                   
* Why maintaining::             
* MSDOS::                       

Tutorial Introduction to @code{tar}

* How to Create Archives::      
* How to List Archives::        
* How to Extract Members from an Archive::  
* How to Add Files to Existing Archives::  
* How to Delete Members from Archives::  

How to Create Archives

* Creating Archives of Files bis::  
* Using tar in Verbose Mode bis::  
* How to Archive Directories::  
* Creating an Archive of a Subdirectory bis::  
* Compare bis::                 
* Using Compare from the Superior Directory bis::  

How to Archive Directories 

* Creating an Archive of a Subdirectory bis::  

How to List Archives

* Listing files in an archive bis::  
* Getting Additional File Information bis::  
* List A Specific File in an Archive bis::  
* Listing the Contents of a Stored Directory ter::  

How to Extract Members from an Archive

* Extracting Files bis::        
* Extracting Files from an Archive ter::  
* Extracting Specific Files ter::  
* Extracting Directories ter::  

How to Add Files to Existing Archives

* Append bis::                  
* Update bis::                  
* Concatenate bis::             

Invoking GNU @code{tar}

* Synopsis::                    
* Option Styles::               
* Options::                     

Many Styles for Options

* Mnemonic Options::            
* Short Options::               
* Old Options::                 
* Mixing Styles::               

All Available Options

* Device Options::              
* Blocking Options::            
* Classification Options::      

Basic @code{tar} Operations

* Creating a New Archive::      
* Adding to an Existing Archive::  
* Updating an Archive::         
* Combining Archives::          
* Removing Archive Members::    
* Listing Archive Members::     
* Extracting Archive Members::  
* Comparing Archives Members with Files::  
* Matching Format Parameters::  

Extracting Archive Members

* Archive Reading Options::     
* File Writing Options::        
* Scarce Disk Space::           

Specifying Names to @code{tar}

* Changing the Archive Name::   
* Characteristics::             
* Selection Options::           

Selecting Files by Characteristic

* Reading Names from a File::   
* Excluding Some Files::        
* Operating Only on New Files::  
* Crossing Filesystem Boundaries::  

Local file selection

* Changing Directory::          
* Absolute File Names::         

Being Even More Careful

* Documentation::               
* Checking Progress::           
* Interactive Operation::       
* Write Verification::          
* Comparing::                   
* Portability::                 
* Write Protection::            

Making @code{tar} Archives More Portable

* Portable Names::              
* Symbolic Links::              
* Old V7 and POSIX::            
* Checksumming Problems::       

Controlling the Archive Format

* Attributes Options::          
* Type Options::                
* Compression::                 
* Special Options for Archiving::  
* Archive Structure::           
* Modifiers Options::           

Using Less Space through Compression

* Compressed Archives::         
* Dealing with Compressed Archives::  
* Sparse Files::                

Tapes and Other Archive Media

* Device::                      
* Blocking::                    
* Many::                        
* Using Multiple Tapes::        
* Archive Label::               

Blocking

* Format Variations::           
* Blocking Factor::             

Many archives on one tape

* Tape Positioning::            
* mt::                          

Using Multiple Tapes

* Multi-Volume Archives::       
* Tape Files::                  

Performing Backups and Restoring Files

* Full Dumps::                  
* Inc Dumps::                   
* incremental and listed-incremental::  
* Backup Levels::               
* Backup Parameters::           
* Scripted Backups::            
* Scripted Restoration::        

Setting Parameters for Backups and Restoration

* backup-specs example::        
* Script Syntax::               

Date input formats

* General date syntax::         
* Calendar date item::          
* Time of day item::            
* Timezone item::               
* Day of week item::            
* Relative item in date strings::  
* Pure numbers in date strings::  
* Authors of getdate::          

Format of @code{tar} archives

* Standard::                    
* Extensions::                  
* cpio::                        
@end menu

@node Introduction, Tutorial, Top, Top
@chapter Introduction

This chapter introduces of a few words which will recur all over
this manual, like ``archive'', ``member'', ``name'', ``unpack'', etc.
It then explains who wrote GNU @code{tar} and its documentation, and
says where to send bug reports or comments.

@menu
* What tar Does::               
* Authors::                     
* Bug reports::                 
* Support::                     
@end menu

@node What tar Does, Authors, Introduction, Introduction
@section What @code{tar} Does

@cindex archive
@cindex tar archive
The @code{tar} program is used to create and manipulate @code{tar}
archives.  An @dfn{archive} is a single file which contains within it
the contents of many files.  In addition, the archive identifies the
names of the files, their owner, and so forth.  (Archives record access
permissions, user and group, size in bytes, and last modification time.
Some archives also record the file names in each archived directory,
as well as other file and directory information.)

@cindex member
@cindex archive member
@cindex file name
@cindex member name
The files inside an archive are called @dfn{members}.  Within this
manual, we use the term @dfn{file} to refer only to files accessible in
the normal ways (by @code{ls}, @code{cat}, and so forth), and the term
@dfn{members} to refer only to the members of an archive.  Similarly, a
@dfn{file name} is the name of a file, as it resides in the filesystem,
and a @dfn{member name} is the name of an archive member within the
archive.

@cindex tar
Initially, @code{tar} archives were used to store files conveniently
on magnetic tape.  The name @samp{tar} comes from this use; it stands
for: @code{t}ape @code{ar}chiver.  Despite the utility's name,
@code{tar} can direct its output to any available device, as well
as store it in a file or direct it to another program via a pipe.
@code{tar} may even access, as archives, remote devices or files.

You can use @code{tar} archives in many ways.  We want to stress a few
of them: storage, backup or transportation.

@table @asis
@item Storage
Often, @code{tar} archives are used to store related files for
convenient file transfer over a network.  For example, the GNU Project
distributes its software bundled into @code{tar} archives, so that
all the files relating to a particular program (or set of related
programs) can be transferred as a single unit.

A magnetic tape can store several files in sequence, but has no names
for them, just relative position on the tape.  A @code{tar} archive or
something like it is one way to store several files on one tape and
retain their names.  Even when the basic transfer mechanism can keep
track of names, as FTP can, the nuisance of handling multiple files,
directories, and multiple links, makes @code{tar} archives an attractive
method.

Archive files are also used for long-term storage, which you can
think of as transportation from one time to another.

@item Backup
Because the archive created by @code{tar} is capable of preserving
file information and directory structure, @code{tar} is commonly used
for performing full and incremental backups of disks, putting all
together bunch of files possibly pertaining to many users and different
projects, to secure against accidental destruction of those disks.

The GNU version of @code{tar} has special features that allow it
to be used to make incremental and full dumps of all the files in
a filesystem.

@item Transportation
Archive files can be used for transporting a group of files from one
system to another: put all relevant files into an archive on one
computer system, transfer the archive to another, and extract the
contents there.  The basic transfer medium might be magnetic tape,
Internet FTP, or even electronic mail (though you must encode the
archive with @code{uuencode} or some functional equivalent in order to
transport it properly by mail).  Both machines do not have to use the
same operating system, as long as they both support the @code{tar}
program.

Piping one @code{tar} to another is an easy way to copy a directory's
contents from one disk to another, while preserving the dates, modes,
owners and link structure of all the files therein.  @code{tar} is also
ideal for transferring directories over networks.  We sometimes see a
copy of @code{tar} packing many files into one archive on one machine,
and sending the produced archive over a pipe over the network to another
copy of @code{tar} on another machine, reading its archive from the pipe
and unpacking all files there.

@end table

@cindex extraction
@cindex unpacking
The @code{tar} program provides the ability to create @code{tar}
archives, as well as for various other kinds of manipulation.
For example, you can use @code{tar} on previously created archives to
extract files, to store additional files, or to update or list files
already stored.  The term @dfn{extraction} is used to refer to the
process of copying an archive member into a file in the filesystem.
One might speak of extracting a single member.  Extracting all
the members of an archive is often called extracting the archive.
Also, the term @dfn{unpack} is used to refer to the extraction of
many or all the members of an archive.

Conventionally, @code{tar} archives are given names ending with
@samp{.tar}.  This is not necessary for @code{tar} to operate properly,
but this manual follows the convention in order to get the reader used
to seeing it.

@cindex tar file
@cindex entry
@cindex tar entry
Occasionally, @code{tar} archives are referred to as @code{tar} files,
archive members are referred to as files, or entries.  For people
familiar with the operation of @code{tar}, this causes no difficulty.
However, this manual consistently uses the terminology above in
referring to archives and archive members, to make it easier to learn
how to use @code{tar}.

@node Authors, Bug reports, What tar Does, Introduction
@section GNU @code{tar} Authors

GNU @code{tar} was originally written by John Gilmore, and modified
by many people.  The GNU enhancements were written by Jay Fenlason,
and the whole package has been further maintained by Michael Bushnell,
then @value{Francois} Pinard, with the help of numerous and kind users.
I wish to stress that @code{tar} is somewhat a collective work, and
owe much to all those people who reported problems, offerred solutions
and other insights, or shared their thoughts and suggestions.  Even if
we lost track of many of those contributors, a partial list can be
found in the @file{THANKS} file from the GNU @code{tar} distribution.

Jay Fenlason put together a draft of a GNU @code{tar} manual, also
borrowing notes from the original man page from John Gilmore,
this draft has been distributed in @code{tar} versions 1.04
(or even before?) through 1.10, then withdrawn in version 1.11.
Michael Bushnell and Amy Gorin worked at a tutorial and manual for GNU
@code{tar}, and left a few unpublished versions of each.  For version
1.11.8, @value{Francois} Pinard put together a new manual by grabbing
from all these sources and merging them in a single manual.
@c FIXME: Karl Berry proofread and properly indexed the thing.

@cindex incompleteness of this manual
I heard that there is another manual in the works, by another team,
which should say everything about archives and related utilities, and
which will surely be nicer than this one.  In the meantime, please
consider this manual is a placeholder for @code{tar} option list and
a few random notes the maintainer wants to save somewhere, so users
can read them.  I wish GNU @code{tar} users will be happier with this
imperfect manual than with no documentation at all.

@node Bug reports, Support, Authors, Introduction
@section Reporting bugs or suggestions

@cindex bug reports
@cindex reporting bugs
Please report problems or suggestions about this program to
@file{bug-gnu-utils@@prep.ai.mit.edu}.  You may also write directly,
and less officially, to @file{pinard@@iro.umontreal.ca}.  There is a
lot of mail flowing about @code{tar}, and some accumulated in the past
years.  You might expect a quick acknowledgement of your invoices, but
the proper handling of your reports may be delayed for a long while.

Many nodes of this document have not been revised much, these all start
with a little comment telling so.  I accept documentation bug reports,
of course.  But please do not torture yourself into systematically
reporting all inadequacies for the unrevised nodes of this document,
unless you really feel like revising them.

@node Support,  , Bug reports, Introduction
@section Support considerations

This informal appendix is for the maintainer to share a few words
and thoughts, while considering GNU @code{tar} support.

@menu
* Stability::                   
* Rewriting::                   
* Why maintaining::             
* MSDOS::                       
@end menu

@node Stability, Rewriting, Support, Support
@subsection Stability of GNU @code{tar}

User reports mainly fall in three categories: portability problems,
execution bugs, and requests for enhancements.  For 1.11.X, the
emphasis has been on solving portability problems, then trying to make
GNU @code{tar} more solid.  Enhancements have fairly low priority,
yet I sometime slip one in just for taking a kind of rest :-).

Many bugs have been corrected since 1.11.2.  If you are curious,
glance through ChangeLog.  I had only very few reports for things
that @emph{might} be new bugs not present in 1.11.2.  If you
are really curious, and have access to the FSF machines, see
@file{/gd/gnu/tar/rmail/} hierarchy for all reports.  Subdirectories
@file{0}, @file{1}, @file{2} and @file{3} represent decreasing levels
in priority.  Most problems in there were reported against 1.10,
1.11 or 1.11.2 and still exist.  The only thing I have consciously
broken between 1.11.2 and 1.11.5 is @value{record-number},
because I wanted some modification to be done to @file{gnulib/error.c},
which is outside my control.  This modification is now done, but I
did not revisit this area yet.

Here is my candid opinion.  GNU @code{tar} has many areas of
unreliability.  See @file{BACKLOG} for the horrorful picture of
the situation.  Yet, for most users and usages, GNU @code{tar} looks
very dependable.  For me as a mere user, GNU @code{tar} did not give
problems in years.  And I think it offers a lot of functionality.
Many problems have been solved since 1.11.2, even if true that many
more remain to be solved.  I'm not discouraged myself and feel positive
about maintaining it, simply because when I bite, that usually lasts
for quite long.  I might not have all the time I would want, but I
surely have good will and am happily surrounded by many collaborating
pretesters.  So, I still think GNU @code{tar} is on the winning side
in the long run.

@node Rewriting, Why maintaining, Stability, Support
@subsection Should we rewrite the thing?

Working in @code{tar} sources is not always pleasurable.  The problem is
that @code{tar} sources are very fragile.  Just cleaning around breaks
things.  The current sequence of prereleases is for slowly trying
to solidify it, so @code{tar} becomes more maintainable.  I think that
the ugliness of sources could be corrected to a certain extent, too.

A few efforts to replace GNU @code{tar} have been done already and it
seems that all failed so far.  A toy program, for me, is another kind
of failure.  I think people underestimate the number of portability
problems such a program can raise.  This is not only a matter of
programming style, there is really a wide variability in systems
out there.  GNU @code{tar} has a long history, met a rich variety
of porting problems, machine peculiarities, system idiosyncrasies,
which are unrelated to programming style.  My own opinion is that we
cannot dismiss all the experience gleaned along the years, and saved
(if not hidden) in GNU @code{tar} sources, pretending to start anew,
from scratch.

Even if a new program replacing GNU @code{tar} would be marvelous, GNU
@code{tar} stalled for a few years waiting for such a program, and we
are now faced to nothing, with hundreds of user reports to catch on.
We need a working archiver @emph{now}, and cannot live on promises.
Any new program will take hundreds of user reports, and many years,
to stabilize enough to become a plausible @code{tar} replacement.
I rather plan to clean up GNU @code{tar}.  This alone is a big task for
me, because GNU @code{tar} coding is not ideal, and I have to find ways
to transform it slowly, while having it fully working at all times.

@node Why maintaining, MSDOS, Rewriting, Support
@subsection Why maintaining it?

I confess that I am a little afraid of @code{tar} maintainance.
It is difficult for many reasons, the first tree being more evident
than the others:

@itemize @bullet
@item
the algorithmic design was initially oriented for machines having
very small memory, it was later much adapted for new features
without doing everything necessary for the whole to stay clean;

@item
the wide visibility of @code{tar} forces many stunts at portability;

@item
GNU @code{tar} has to be sensitive to file systems and device variance. 

@item
GNU central has been seduced by some users promising to write
wonderful @code{tar} replacements, which never came, so development
has been put aside for years, while bug reports accumulated;

@item
the @code{tar} manual has been withdrawn, promising users a fine
replacement for it, so raising their expectations;

@item
maintenance was once split between four maintainers (one for
@code{tar}, one for @code{mt}, another for scripts, and a team for
documentation), and also, @file{rtapelib.[ch]} from @code{tar} is
used in @code{cpio}, and synchronisation has not always been easy.

@end itemize

However, even if difficult, I do feel like doing a careful cleanup,
so @code{tar} would become less painful to maintain after a while
(and less subject to criticism).  And besides, I'm surrounded by a
marvelous team of pretesters and by many other collaborating users,
which I should learn to serve better.  Getting more experience
with maintainance in GNU, I hope being careful enough modifying
@code{tar} so not hurting users too much, being aware that @code{tar}
is a sensitive product in GNU.  Once cleaned up, I might be happy to
return @code{tar} maintainance to someone else@dots{}

@code{tar} requires more work alone that all my other things together,
and I have to resist being swallowed whole in it.  This resistance
makes @code{tar} development somewhat slower.  Sorry!

@node MSDOS,  , Why maintaining, Support
@subsection MSDOS and other systems?

GNU does not necessarily support non-UNIX systems, that is to say,
MSDOS is not supported.  It is very true that ports can sometimes be
very intrusive in the sources, cluttering them significantly with
conditionals and extra code, and distract GNU maintainers from the
main development line.

However, a special argument might be made for @code{tar}.
Both @code{tar} and @code{gzip} are the required tools for getting
something out of the GNU archives, @code{tar} should be more opened
to ports than the GNU rule states.  Jean-loup did a tremendous job at
porting @code{gzip} on smaller systems.  It would be comfortable that
a few other GNU tools be available on MSDOS and others, among which
@code{tar}.  These ports for @code{tar} have theoretically no priority
at all.  Nevertheless, a port is interesting, because @code{tar} is
so central in GNU distributions, and @code{gzip} is already ported.

Some porting efforts have been done in the past.  There are traces of
a few exchanges on this subject in @file{BACKLOG}.  GNU @code{tar}
sources have been modified a lot recently at a cosmetic level, and
I would certainly have a hard time integrating diffs provided by
someone else.  If people want porting @code{tar} to MSDOS or other
non-UNIX systems, they should be committed in supporting their ports
after the fact, as I cannot do it myself.

@node Tutorial, Invoking tar, Introduction, Top
@chapter Tutorial Introduction to @code{tar}

This chapter guides you through some basic examples of @code{tar}
operations.  If you already know how to use some other version of
@code{tar}, then you probably don't need to read this chapter.  This
chapter omits complicated details about many of the ways @code{tar}
works.  See later chapters for full information.

Before proceeding further with this tutorial chapter, be sure you
understand already and clearly what is meant by ``archive'' and
``archive member''.
@format
FIXME: xref What tar Does
@end format
.

This chapter guides you through some basic examples of @code{tar}
operations.  In the examples, the lines you should type are preceded by
a @samp{%}, which is a typical shell prompt.  We use mnemonic forms of
operations and options in the examples, and in discussions in the text,
but short forms produce the same result.

Most of the options to @code{tar} come in both long forms and short
forms.  The options described in this tutorial have the following
abbreviations (except @value{delete}, which has no shorthand form):

@table @samp
@item --create
@samp{-c}
@item --list
@samp{-t}
@item --extract
@samp{-x}
@item --append
@samp{-r}
@item --verbose
@samp{-v}
@item --file=@var{archive-name}
@samp{-f @var{archive-name}}
@end table

These options make typing long @code{tar} commands easier.  For example,
instead of typing
@example
tar --create --file=/tmp/afiles.tar --verbose apple angst asparagus
@end example
you can type
@example
tar -c -f /tmp/afiles.tar -v apple angst asparagus
@end example

For more information on option syntax,
@format
FIXME: ref Invoking tar
@end format
.
In discussions in the text, when we present some mnemonic option, we
also give the corresponding short option within parentheses.

@menu
* How to Create Archives::      
* How to List Archives::        
* How to Extract Members from an Archive::  
* How to Add Files to Existing Archives::  
* How to Delete Members from Archives::  
@end menu

@node How to Create Archives, How to List Archives, Tutorial, Tutorial
@section How to Create Archives
@include docwarn.texi

To create a new archive, use the @value{create} option to @code{tar}.
You can use options to specify the name and format of the archive (as
well as other characteristics), and you can use file name arguments
to specify which files and directories are to be put in the archive.

@format
FIXME: xref Creating
@end format
, for more information about the @value{create}
operation.

To create a new archive, use the @value{create} option to @code{tar}.
You should generally use the @value{file} option to specify the name
the @code{tar} archive will have.  Then specify the names of the
files you wish to place in the new archive.  For example, to place
the files @file{apple}, @file{angst}, and @file{asparagus} into an
archive named @file{afiles.tar}, use the following command:

@example
tar --create --file=afiles.tar apple angst asparagus
@end example

The order of the arguments is not important when using mnemonic option
style.  You could also say:

@example
tar apple --create angst --file=afiles.tar asparagus
@end example

This order is harder to understand however.  In this manual, we will
list the arguments in a reasonable order to make the commands easier to
understand, but you can type them in any order you wish.

If you don't specify the names of any files to put in the archive,
then @code{tar} will create an empty archive.  So, the following
command will create an archive with nothing in it:

@example
tar --create --file=empty-archive.tar
@end example

Whenever you use @value{create}, @code{tar} will erase the current
contents of the file named by @value{file} if it exists.  To add files
to an existing archive, you need to use a different option.
@format
FIXME: xref Adding to Archives, for information on how to do this.
@end format

When an archive is created through @value{create}, the member names of the
members of the archive are exactly the same as the file names as you
typed them in the @code{tar} command.  So, the member names of
@file{afiles} (as created by the first example above) are @file{apple},
@file{angst}, and @file{asparagus}.  However, suppose an archive were
created with this command:

@example
tar --create --file=bfiles.tar ./balloons baboon ./bodacious
@end example

Then, the three files @file{balloons}, @file{baboon}, and
@file{bodacious} would get placed in the archive (because @file{./} is a
synonym for the current directory), but their member names would be
@file{./balloons}, @file{baboon}, and @file{./bodacious}.

If you want to see the progress of @code{tar} as it writes files into the
archive, you can use the @value{verbose} option.

If one of the files named with @value{create} is a directory, then
the operation of @code{tar} is more complicated.
@format
FIXME: xref Tar and Directories,
FIXME: the last section of this tutorial, for more information.
@end format

If you don't specify the @value{file} option, then @code{tar} will use
a default.  Usually this default is some physical tape drive attached to
your machine.  If there is no tape drive attached, or the default is not
meaningful, then @code{tar} will print an error message.  This error message
might look roughly like one of the following:

@example
tar: can't open /dev/rmt8 : No such device or address
tar: can't open /dev/rsmt0 : I/O error
@end example

If you get an error like this, mentioning a file you didn't specify
(@file{/dev/rmt8} or @file{/dev/rsmt0} in the examples above), then @code{tar}
is using a default value for @value{file}.  You should generally specify a
@value{file} argument whenever you use @code{tar}, rather than relying
on a default.

To create a new archive, use the @value{create} option to
@code{tar}.  You can use options to specify the name and format of
the archive (as well as other characteristics), and you can use
file name arguments to specify which files to put in the archive.
If you don't use any options or file name arguments, @code{tar} will
use default values.
@format
FIXME: xref Creating Example
@end format
, for more information
about the @value{create} option.

@menu
* Creating Archives of Files bis::  
* Using tar in Verbose Mode bis::  
* How to Archive Directories::  
* Creating an Archive of a Subdirectory bis::  
* Compare bis::                 
* Using Compare from the Superior Directory bis::  
@end menu

@node Creating Archives of Files bis, Using tar in Verbose Mode bis, How to Create Archives, How to Create Archives
@subsection Creating Archives of Files
@include docwarn.texi

This example shows you how to create an archive file in your working
directory containing other files in the same directory.  The three
files you archive in this example are called @file{blues},
@file{folk}, and @file{jazz}.  The archive file is called
@file{records}.  While the archive in this example is written to the
file system, it could also be written to tape.  (If you want to follow
along with this and future examples, create a practice subdirectory
containing files with these names.  To create the directory, type
@samp{mkdir practice} at the system prompt.  You can create the files
using a text editor, such as @code{emacs}).

While in the directory containing the files you want to archive, list
the directory's contents.

Type:

@example
% cd practice
% ls 
@end example

@noindent
The system responds:

@example
blues	folk	jazz
%
@end example

@noindent
This is to check that the files to be archived do in fact exist in the
working directory, and to check that the archive name you have chosen
isn't already in use.  If it is, @code{tar} will overwrite the old
archive and its contents will be lost.

Then,
@itemize @bullet
@item
Create a new archive by giving @value{create} to @code{tar}.
@item
Explicitly name the archive file being created---@value{file}.
If you don't use this option @code{tar} will write the archive to
the default storage device, which varies from system to system.
@item
Specify which files to put into the archive.  If you don't specify any
@var{file name} arguments, @code{tar} will archive everything in the
working directory.
@end itemize

@noindent
Type:
@example
% tar --create --file=records blues folk jazz 
@end example

@noindent
If you now list the contents of the working directory (@samp{ls}), you
will find the archive file listed as well as the files you saw
previously.

@example
% ls
blues folk jazz records
%
@end example

This example shows you how to create an archive file in the working
directory containing other files in the working directory.  The three
files you archive in this example are called @file{blues}, @file{folk}, and
@file{jazz}.  The archive file is called @file{records}.  While the archive in
this example is written to the file system, it could also be written to
any other device.

(If you want to follow along with this and future examples, create a
directory called @file{practice} containing files called @file{blues}, @file{folk} and
@file{jazz}.  To create the directory, type @samp{mkdir practice} at the system
prompt.  It will probably be easiest to create the files using a text
editor, such as Emacs.)

First, change into the directory containing the files you want to
archive:

@example
% cd practice
@end example

@file{~/practice} is now your working directory.

Then, check that the files to be archived do in fact exist in the
working directory, and make sure there isn't already a file in the
working directory with the archive name you intend to use.  If you
specify an archive file name that is already in use, @code{tar} will
overwrite the old file and its contents will be lost.

To list the names of files in the working directory, type:

@example
% ls
@end example

The system responds:

@example
blues   folk    jazz
%
@end example

Then,

@itemize @bullet

@item
Create a new archive by giving the @value{create} option to
@code{tar}.

@item
Explicitly name the archive file being created---@value{file}.  If you
don't use this option @code{tar} will write the archive to the default
storage device, which varies from system to system.
@format
FIXME: this syntax may change.  OK now--check before printing
@end format

@code{tar} interprets archive file names relative to the working
directory.  Make sure you have write access to the working
directory before using @code{tar}.

@item
Specify which files to put into the archive (@code{tar} interprets
file names relative to the working directory).  If you don't use
any @var{name} arguments, @code{tar} will archive everything in the
working directory.

@end itemize

Type:
@example
% tar --create --file=records blues folk jazz
@end example

If you now list the contents of the working directory (@samp{ls}), you will
find the archive file listed as well as the files you saw previously.

@example
% ls
blues folk jazz records
%
@end example

@node Using tar in Verbose Mode bis, How to Archive Directories, Creating Archives of Files bis, How to Create Archives
@subsection Using @code{tar} in Verbose Mode
@include docwarn.texi

If you include the @value{verbose} option on the command
line, @code{tar} will list the files it is acting on as it is working.
The example above in verbose mode would be:
@refill

@example
% tar --create --file=records --verbose blues folk jazz
blues
folk
jazz

@end example

@noindent
The first line, which is preceeded by a @samp{%}, is the command line.
The lines after the first line are generated by @code{tar} as it
works.  In the following examples we usually use verbose mode, though
it is almost never required.

If you include the @value{verbose} option on the command line,
@code{tar} will list the files it is acting on as it is working. In verbose
mode, the creation example above would appear as:

@example
% tar --create --file=records --verbose blues folk jazz
blues
folk
jazz
@end example

The first line is the command typed in by the user.  The remaining
lines are generated by @code{tar}.  In the following examples we usually use
verbose mode, though it is almost never required.

@node How to Archive Directories, Creating an Archive of a Subdirectory bis, Using tar in Verbose Mode bis, How to Create Archives
@subsection How to Archive Directories 
@include docwarn.texi

When the names of files or members specify directories, the operation of
@code{tar} is more complex.  Generally, when a directory is named,
@code{tar} also operates on all the contents of the directory,
recursively.  Thus, to @code{tar}, the file name @file{/} names the
entire file system.

To archive the entire contents of a directory, use @value{create} or @value{append} as usual, and specify the name of the
directory.  For example, to archive all the contents of the current
directory, use @samp{tar --create --file=@var{archive-name} .}.  Doing
this will give the archive members names starting with @samp{./}.  To
archive the contents of a directory named @file{foodir}, use @samp{tar
--create --file=@var{archive-name} foodir}.  In this case, the member
names will all start with @samp{foodir/}.

If you give @code{tar} a command such as @samp{tar --create
--file=foo.tar .}, it will report @samp{tar: foo.tar is the archive; not
dumped}.  This happens because the archive @file{foo.tar} is created
before putting any files into it.  Then, when @code{tar} attempts to add
all the files in the directory @file{.} to the archive, it notices that
the file @file{foo.tar} is the same as the archive, and skips it.  (It
makes no sense to put an archive into itself.)  GNU @code{tar} will
continue in this case, and create the archive as normal, except for the
exclusion of that one file.  Other versions of @code{tar}, however, are
not so clever, and will enter an infinite loop when this happens, so you
should not depend on this behavior.  In general, make sure that the
archive is not inside a directory being dumped.

When extracting files, you can also name directory archive members on
the command line.  In this case, @code{tar} extracts all the archive
members whose names begin with the name of the directory.  As usual,
@code{tar} is not particularly clever about interpreting member names.
The command @samp{tar --extract --file=@var{archive-name} .} will not
extract all the contents of the archive, but only those members whose
member names begin with @samp{./}.

@menu
* Creating an Archive of a Subdirectory bis::  
@end menu

@node Creating an Archive of a Subdirectory bis, Compare bis, How to Archive Directories, How to Create Archives
@subsection Creating an Archive from the Superior Directory
@include docwarn.texi

You can archive a directory by specifying its directory name as a
file name argument to @code{tar}.  The files in the directory will be
archived relative to the working directory, and the directory will be
re-created along with its contents when the archive is extracted.

To archive a directory, first move to its superior directory.  If you
have been following the tutorial, you should type:

@example
% cd ..
%
@end example

Once in the superior directory, you can specify the subdirectory as a
file name argument.  To store the directory @file{practice} in the
archive file @file{music}, type:

@example
% tar --create --verbose --file=music practice
@end example

@noindent
@code{tar} should output:

@example
practice/
practice/blues
practice/folk
practice/jazz
practice/records
@end example

Note that the archive thus created is not in the subdirectory
@file{practice}, but rather in the working directory---the directory
from which @code{tar} was invoked.  Before trying to archive a
directory from its superior directory, you should make sure you have
write access to the superior directory itself, not only the directory
you are trying archive with @code{tar}.  Trying to store your home
directory in an archive by invoking @code{tar} from the root directory
will probably not work.
@format
FIXME: xref absolute-names
@end format
(Note also that
@file{records}, the original archive file, has itself been archived.
@code{tar} will accept any file as a file to be archived, regardless
of its content.  When @file{music} is extracted, the archive file
@file{records} will be re-written into the file system).

You can store a directory in an archive by using the directory name
as a file name argument to @code{tar}.  When you specify a directory file,
@code{tar} archives the directory file and all the files it contains.  The
names of the directory and the files it contains are stored in the
archive relative to the current working directory--when the directory
is extracted they will be written into the file system relative to the
working directory at that time.
@format
FIXME: add an xref to --absolute-names
@end format

To archive a directory, first move to its superior directory.  If you
have been following the tutorial, you should type:

@example
% cd ..
%
@end example

Once in the superior directory, specify the subdirectory using a
file name argument.  To store the directory file @file{~/practice} in the
archive file @file{music}, type:

@example
% tar --create --verbose --file=music practice
@end example

@code{tar} should respond:

@example
practice/
practice/blues
practice/folk
practice/jazz
practice/records
@end example

Note that @file{~/practice/records}, another archive file, has itself
been archived.  @code{tar} will accept any file as a file to be archived,
even an archive file.

@format
FIXME: symbolic links and changing directories are now in main body,
FIXME: not in tutorial.
@end format

@node Compare bis, Using Compare from the Superior Directory bis, Creating an Archive of a Subdirectory bis, How to Create Archives
@subsection Comparing Files in an Archive with Files in the File System
@include docwarn.texi

While the @value{list} operation with the @value{verbose} option
specified is useful in keeping files in the archive current with files
in the file system (by allowing the user to compare size and
modification dates), it is simpler to have @code{tar} itself compare
file attributes and report back on file differences.  To do so, use
the @value{compare} or @samp{--diff} operation.

The @value{compare} operation, as its name implies, causes @code{tar}
to compare files and directories in the archive with their
counterparts (files of the same name) in the file system, and report
back differences in file size, mode, owner and modification date.
When performing the @value{compare} operation, @code{tar} acts only on
files actually in the archive---it will ignore files in the active
file system that do not exist in the archive.  If @code{tar} with
@value{compare} specified is given, as a file name argument, the name
of a file that does not exist in the archive, it will return an error
message.

To compare the files in the practice directory with their counterparts
in the archive file @file{records}, in the same directory, you would,
while in the @file{practice} directory:

@itemize @bullet
@item
Invoke @code{tar} and specify the operation to compare files in the
archive with their counterparts in the file system---@value{compare}
or @samp{--diff}.
@item
Specify the name of the archive where the files to be compared are
stored---@value{file}.
@item
Specify the names of the files or directories to be compared, as
file name arguments (in this case, you are comparing all the files in
the archive, so nothing need be specified).
@end itemize

@example
% tar --compare --file=records
%
@end example

@noindent
While it looks like nothing has happened, @code{tar} has, in fact,
done the comparison---and found nothing to report.  The same example
with the @value{verbose} option specified would list the files in the
archive as they are being compared with their counterparts of the same
name:

@example
% tar --compare --verbose --file=records
blues
folk
jazz
%
@end example

If @code{tar} had had anything to report, it would have done so as it
was comparing each file.  If you remove the file @file{jazz} from the
file system (@samp{rm jazz}), and modify the file @file{blues} (for
instance, by adding text to it with a text editor), the above example
would look like:

@example
% tar --compare --verbose --file=records
blues
blues: mod time differs
blues: size differs
folk
jazz
jazz: does not exist
% 
@end example

You should note again that while @value{compare} does cause @code{tar}
to report back on files in the archive that do not exist in the file
system, @code{tar} will ignore files in the active file system that do
not exist in the archive.  To demonstrate this, create a file in the
@file{practice} directory called @file{rock} (using any text editor).
If you generate a directory listing the new file will appear.

@example
% ls
blues	 folk	  records  rock
@end example

@noindent
If you run the @value{compare} example again you will obtain the
following:

@example
% tar --compare --verbose --file=records
blues
blues: mod time differs
blues: size differs
folk
jazz
jazz: does not exist
% 
@end example

@code{tar} ignores the file @file{rock} because @code{tar} is
comparing files in the archive to files in the file system, not vice
versa.  If @file{rock} had been passed to @code{tar} explicitly (as a
file name argument), @code{tar} would have returned an error message,
as follows:

@example
% tar --compare --verbose --file=records rock
tar: rock not found in archive
% 
@end example

To compare the attributes of archive members with the attributes of
their counterparts in the file system, use the @value{compare} or
@samp{--diff}operation.  While you could use @samp{--list --verbose}
(@samp{-tv}) to manually compare some file attributes, it is simpler
to have @code{tar} itself compare file attributes and report back on
file differences.
@format
FIXME: "manually"?  suggestions?
@end format

The @value{compare} operation, as its name implies, compares archive
members with files of the same name in the file system, and reports
back differences in file size, mode, owner and modification date. @samp{tar
+compare} acts only on archive members--it ignores files in the file
system that are not stored in the archive.  If you give with
@value{compare}
a @var{name} argument that does not correspond to the name of an archive
member, @code{tar} responds with an error message.

To compare archive members in the archive file @file{records} with files
in the @file{~/practice} directory, first change into the @file{practice}
directory.  Then:

@itemize @bullet
@item
Invoke @code{tar} and specify the @value{compare}
operation---@value{compare} or @samp{--diff}.

@item
Specify the archive where the files to be compared are
stored---@value{file}.

@item
Specify the archive members to be compared.  (In this example you
are comparing all the archive members in the archive.  Since this
is the default, you don't need to use any file name arguments).
@end itemize

@example
% tar --compare --file=records
%
@end example

While it looks like nothing has happened, @code{tar} has, in fact, done the
comparison---and found nothing to report.

Use the @value{verbose} option to list the names of archive members as
they are being compared with their counterparts of the same name in the
file system:

@example
% tar --compare --verbose --file=records
blues
folk
jazz
%
@end example

If @code{tar} had had anything to report, it would have done so as it was
comparing each file.

If you remove the file @file{jazz} from the file system (@samp{rm jazz}), and
modify the file @file{blues} (for instance, by adding text to it with an
editor such as Emacs), the above example would look like:

@example
% tar --compare --verbose --file=records
blues
blues: mod time differs
blues: size differs
folk
jazz
jazz: does not exist
%
@end example

Note again that while @value{compare} reports the names of archive
members that do not have counterparts in the file system,
@value{compare} ignores files in the file system that do not have
counterparts in the archive.  To demonstrate this, create a file in the
@file{practice} directory called @file{rock} (using any text editor).  The new
file appears when you list the directory's contents:

@format
FIXME: Given an example
@end format

@node Using Compare from the Superior Directory bis,  , Compare bis, How to Create Archives
@subsection Using Compare from the Superior Directory
@include docwarn.texi

In addition to using @value{compare} to compare individual files in an
archive with their counterparts in the file system, you can use
@value{compare} to compare archived directories with their
counterparts in the active file system.  You could re-create the
examples above using your home directory as the working directory, and
using the archive file @file{music} (in which is stored the
@file{practice} directory) instead of the archive file @file{records}.

First, change into the home directory (@samp{cd ..}).  Then, try the
above example using @file{music} as the specified archive file, and
the @file{practice} subdirectory as a file name argument.

@example
% tar --compare --verbose --file=music practice
practice
practice/blues
practice/blues: mod time differs
practice/blues: size differs
practice/folk
practice/jazz
practice/jazz: does not exist
practice/records
@end example

In addition to using @value{compare} to compare text files, you can use
@value{compare} to compare directories.  To illustrate this, re-create the
examples above using your home directory as the working directory, and
using the archive file @file{~/music} instead of the archive file
@file{~/practice/records}.

First, change into your home directory (@samp{cd ~}).  Then, try the
above example using @file{music} as the specified archive file, and
@file{practice} as a file name argument.

@example
% tar --compare --verbose --file=music practice
@end example

If you have been following along with the tutorial, @code{tar} will respond:

@example
practice
practice/blues
practice/blues: mod time differs
practice/blues: size differs
practice/folk
practice/jazz
practice/jazz: does not exist
practice/records
@end example

@node How to List Archives, How to Extract Members from an Archive, How to Create Archives, Tutorial
@section How to List Archives
@include docwarn.texi

Use @value{list} to print the names of members stored in an
archive.  Use a @value{file} option just as with
@value{create} to
specify the name of the archive.  For example, the archive
@file{afiles.tar} created in the last section could be examined with the
command @samp{tar --list --file=afiles.tar}.  The output of @code{tar} would
then be:

@example
apple
angst
asparagus
@end example

The archive @file{bfiles.tar} would list as follows:

@example
./baloons
baboon
./bodacious
@end example

(Of course, @samp{tar --list --file=empty-archive.tar} would produce no
output.)

If you use the @value{verbose} option with @value{list}, then @code{tar} will print out a listing reminiscent of
@samp{ls -l}, showing owner, file size, and so forth.

You can also specify member names when using @value{list}.
In this case, @code{tar} will only list the names of members you
identify.  For example, @samp{tar --list --file=afiles.tar apple}
would only print @samp{apple}.  It is essential when specifying
member names to @code{tar} that you give the exact member names.
For example, @samp{tar --list --file=bfiles baloons} would produce
no output, because there is no member named @file{baloons}, only
one named @file{./baloons}.  While the file names @file{baloons} and
@file{./baloons} name the same file, member names are compared using
a simplistic name comparison, in which an exact match is necessary.

@menu
* Listing files in an archive bis::  
* Getting Additional File Information bis::  
* List A Specific File in an Archive bis::  
* Listing the Contents of a Stored Directory ter::  
@end menu

@node Listing files in an archive bis, Getting Additional File Information bis, How to List Archives, How to List Archives
@subsection Listing the Contents of an Archive
@include docwarn.texi

You can list the contents of the archive you just created with
another option of @code{tar}: @value{list}.  To list the contents of
an archive, type:

@example
% tar --list --file=records
@end example

@code{tar} will respond:

@example
blues folk jazz
@end example


@format
FIXME: xref Listing Archive Contents
@end format
, for a more detailed tutorial of the
@value{list} operation.
@format
FIXME: xref Listing Contents
@end format
for more information
about the @value{list} operation.
@format
FIXME:
@end format

You can use @value{list} to output a list of the files
in an archive.  If you use file name arguments with this operation,
@code{tar} will look in the archive for the files specified and
display their names only if they are, in fact, stored.  You can use
@value{list} with the @value{verbose} option
to find out the attributes (owner, size, etc.) of stored files.

You can list the contents of an archive with another operation of
@code{tar}: @value{list}.  To list the contents of the archive you
just created, type:

@example
% tar --list --file=records
@end example

@code{tar} will respond:

@example
blues folk jazz
@end example


@format
FIXME: xref Listing Archive Contents
@end format
, for a more detailed tutorial of the
@value{list} operation.
@format
FIXME: xref Listing Contents
@end format
, for more information
about the @value{list} operation.

In a previous example, you created the archive @file{music} in the
home directory.  To list the contents of @file{music}:

@itemize @bullet
@item
List the contents of an archive by using @value{list} with @code{tar}.
@item
Specify the name of the archive to be listed---@value{file}.
@end itemize

Thus:

@example
% tar --list --file=music
practice/
practice/blues
practice/folk
practice/jazz
practice/records

@end example

Use @value{list} to print the names of files stored in an
archive.  If you use file name arguments with this operation, @code{tar}
prints the names of the specified files if they are stored in the
archive.  If you use a directory name as a file name argument, @code{tar}
also prints the names of all underlying files, including
sub-directories.  If you use no file name arguments, @code{tar} prints the
names of all the archive members.

You can use @value{list} with the @value{verbose} option to print archive
members' attributes (owner, size, etc.).

To list the names of files stored in an archive, use the @value{list} operation of @code{tar}.

In a previous example, you created the archive @file{~/music}.  To list
the contents of @file{music}, while in your home directory:

@itemize @bullet
@item
List the contents of an archive by using @value{--list} with
@code{tar}.

@item
Specify the archive to be listed---@value{file}.

@end itemize

Thus:

@example
% tar --list --file=music
practice/
practice/blues
practice/folk
practice/jazz
practice/records
@end example

@node Getting Additional File Information bis, List A Specific File in an Archive bis, Listing files in an archive bis, How to List Archives
@subsection Getting Additional File Information
@include docwarn.texi

When you specify the @value{verbose} option in conjunction with
@value{list}, @code{tar} will print additional information about
the files being listed (file protection, owner and group ID, size, and
date and time of creation).  The example above, in verbose mode, would
be:

@example
% tar --list --verbose --file=music
drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
-rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
-rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
-rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
-rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
% 
@end example

Note that using @value{verbose} with @value{list} does not cause @code{tar} to print the names of files
as they are being acted on, though the @value{verbose}
option will have this effect with all other operations.

To get more information when you list the names of files stored in an
archive, specify the @value{verbose} option in conjunction with
@value{list}.

@code{tar} will print archive member's file protection, owner and group ID,
size, and date and time of creation.

For example:

@example
% tar --list --verbose --file=music
drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
-rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
-rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
-rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
-rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
%
@end example

Note that when you use @value{verbose} with @value{list}, @code{tar} doesn't print the names of files as they are
being acted on, though the @value{verbose} option will
have this effect when used with all other operations.

@node List A Specific File in an Archive bis, Listing the Contents of a Stored Directory ter, Getting Additional File Information bis, How to List Archives
@subsection List A Specific File in an Archive
@include docwarn.texi

@format
FIXME:
@end format
To to see if a particular file is in an archive, specify the name of
the file in question as a file name argument while specifying the
@value{list} operation.  For example, if you wanted to see if the file
@file{folk} were in the archive file @file{music}, you would:

@itemize @bullet
@item
Invoke @code{tar}, and specify the operation to list the contents of
an archive---@value{list}.
@item
Specify the name of the archive file to be acted on---@value{file}.
@item
Specify the name of the file @code{tar} is to look for, as a file name
argument.  Because @code{tar} preserves paths, file names must be
specified as they appear in the archive (ie.. as they are relative to
the directory from which the archive was created).
@format
FIXME: xref -P
@end format
@end itemize

Type:

@example
% tar --list --file=music practice/folk
@end example

@noindent
@code{tar} responds:

@example
practice/folk
@end example

@noindent
If the file were not in the archive (for example, the file
@file{practice/rock}), the example above would look like:

@example
% tar --list --file=music practice/rock
tar: practice/rock not found in archive
@end example

The @value{verbose} option does not have any effect
on execution of the @value{list} operation when you have specified
file name arguments.
@format
FIXME: this is a bug (?)
@end format

To to see if a particular file is in an archive, use the name of the
file in question as a file name argument while specifying the
@value{list}
operation.  For example, to see whether the file @file{folk} is in the
archive file @file{music}, do the following:

@itemize @bullet
@item
Invoke @code{tar}, and specify the @value{list} operation.

@item
Specify the archive file to be acted on---@value{file}.

@item
Specify the files to look for, by typing their names as file name
arguments.  You have to type the file name as it appears in the
archive (normally, as it is relative to the relative to the
directory from which the archive was created).
@format
FIXME: xref absolute-names
@end format

@end itemize

Type:

@example
% tar --list --file=music practice/folk
@end example

@code{tar} responds:

@example
practice/folk
@end example

If the file were not stored in the archive (for example, the file
@file{practice/rock}), the example above would look like:

@example
% tar --list --file=music practice/rock
tar: practice/rock not found in archive
@end example

If you had used @value{verbose} mode, the example above
would look like:

@example
% tar --list --file=music practice/folk
-rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
@end example

@node Listing the Contents of a Stored Directory ter,  , List A Specific File in an Archive bis, How to List Archives
@subsection Listing the Contents of a Stored Directory
@include docwarn.texi

To get information about the contents of an archived directory,
use the directory name as a file name argument in conjunction with
@value{list}.  To find out file attributes, include the
@value{verbose} option.

For example, to find out about files in the directory @file{practice}, in
the archive file @file{music}, type:

@example
% tar --list --file=music practice
@end example

@code{tar} responds:

@example
drwxrwxrwx myself/user 0 May 31 21:49 1990 practice/
-rw-rw-rw- myself/user 42 May 21 13:29 1990 practice/blues
-rw-rw-rw- myself/user 62 May 23 10:55 1990 practice/folk
-rw-rw-rw- myself/user 40 May 21 13:30 1990 practice/jazz
-rw-rw-rw- myself/user 10240 May 31 21:49 1990 practice/records
@end example

When you use a directory name as a file name argument, @code{tar} acts on
all the files (including sub-directories) in that directory.

@node How to Extract Members from an Archive, How to Add Files to Existing Archives, How to List Archives, Tutorial
@section How to Extract Members from an Archive
@include docwarn.texi

In order to extract members from an archive, use the @value{extract} option.
Specify the name of the archive with @value{file}.  To extract specific
archive members, give their member names as arguments.  It essential to
give their exact member name, as printed by @value{list}.  This
will create a copy of the archive member, with a file name the same as
its name in the archive.

Keeping the example of the two archives created at the beginning of this
tutorial, @samp{tar --extract --file=afiles.tar apple} would create a
file @file{apple} in the current directory with the contents of the
archive member @file{apple}.  It would remove any file named
@file{apple} already present in the directory, but it would not change
the archive in any way.

Remember that specifying the exact member name is important.  @samp{tar
--extract --file=bfiles.tar baloons} will fail, because there is no
member named @file{baloons}.  To extract the member named
@file{./baloons} you would need to specify @samp{tar --extract
--file=bfiles.tar ./baloons}.  To find the exact member names of the
members of an archive, use @value{list}.
@format
FIXME: xref Listing Archives.
@end format

If you do not list any archive member names, then @value{extract}
will extract all the members of the archive.

If you give the @value{verbose} option, then
@value{extract} will print the names of the archive
members as it extracts them.

@menu
* Extracting Files bis::        
* Extracting Files from an Archive ter::  
* Extracting Specific Files ter::  
* Extracting Directories ter::  
@end menu

@node Extracting Files bis, Extracting Files from an Archive ter, How to Extract Members from an Archive, How to Extract Members from an Archive
@subsection Extract Files from an Archive into Your Current Directory
@include docwarn.texi

Obviously, the ultimate goal of @code{tar} users is to eventually get
their files back.  To do this, use the @value{extract} or @samp{--get}
operation.  @value{extract} can be used to retrieve individual files
from an archive, or can be used to write all the files in the archive
back into the file system.

In the previous example you concatenated two archives, @file{music},
and @file{practice/records}.  To now retrieve the complete contents of
@file{music} (the target file in the concatenation process), you would,
from the home directory:

@itemize @bullet
@item
Invoke @code{tar} and specify the operation to extract files from an
archive (@value{extract} or @samp{--get}.
@item
Specify the name of the archive the files will be extracted
from---@value{file}.
@item
Specify the names of the files you wish to extract, as file name
arguments (in this case you want to extract the entire archive, so you
don't need to specify anything).
@end itemize

@example
% tar --extract --file=music
tar: Could not make directory practice : File exists
@end example

@noindent
Because the files stored originally in @file{music} were stored as
files in a subdirectory (not as files in the working directory), they
are stored in the archive with a leading directory name---@code{tar},
in restoring them, has tried to recreate that directory and failed:
the directory already exists.  The extraction has not been aborted,
however.  If you now change into the @file{practice} directory and
generate a directory listing, you will find that @file{jazz}, which we
removed in an earlier example, has been resurrected.

@example
% cd practice
% ls
blues	   classical  folk	 jazz	    records    rock
@end example

If you look more closely at the files in the directory, however, you
will find that @file{blues} and @file{folk} are, in fact, the original
versions of the file, which were stored in @file{music} at the
beginning of the tutorial.  @code{tar}, in extracting the original
files from @file{music}, has overwritten the existing files in the
file system.

While the newer versions of the files were stored in @file{records}
above, they can no longer be extracted from it.  @file{records} too
was archived by @code{tar} when the @file{practice} directory was
stored in the archive file @file{music}, and was restored to its older
incarnation when the files in @file{practice} were overwritten.
However, the newer version of @file{records} was concatenated with
@file{music}.  The contents of the newer version of @file{records},
therefore, should have been extracted when all the contents of
@file{music} were extracted.  They were.  @code{tar} has restored them
into the working directory using the names with which they were
originally stored.  Because they were originally stored as part of
@file{records}, in the @file{practice} directory, they had no
preceeding directory stored as part of their file names.  To find the
latest versions of @file{blues}, @file{folk}, @file{jazz}, @file{rock}
and @file{classical}, look in your home directory.

You may wish to restore the files in your @file{practice} directory to
their last state before we extracted the files from @file{music}.  Rather
than moving the files from your home directory to the @file{practice}
subdirectory, you can run the same extraction procedure as above using
the @file{practice} subdirectory as your working directory:

@example
% cd practice
% tar --extract --verbose --file=~/music
practice/
practice/blues
practice/folk
practice/jazz
practice/records
blues
folk
jazz
blues
rock
blues
classical
%
@end example

@noindent
If you now examine the files in the practice directory, you will find
that the files have been restored to their previous, newer, states.
The old versions of the files, which were stored in @file{music} with
a preceeding directory name, have been written into a newly created
subdirectory under the working directory (which is your
@file{practice} subdirectory).  The new subdirectory is also called
@file{practice}.

@node Extracting Files from an Archive ter, Extracting Specific Files ter, Extracting Files bis, How to Extract Members from an Archive
@subsection Extracting Files from an Archive
@include docwarn.texi

Creating an archive is only half the job---there would be no point in
storing files in an archive if you couldn't retrieve them.  To extract
files from an archive, use the @value{extract} operation.

To extract specific files, use their names as file name arguments. 
If you use a directory name as a file name argument, @code{tar} extracts all
the files (including subdirectories) in that directory.  If you don't
use any file name arguments, @code{tar} extracts all the files in the
archive.

Note: @code{tar} will extract an archive member into the file system
without checking to see if there is already a file with the archive
member's file name.  If there is a file with that name, @code{tar} will
@emph{overwrite} that file and its contents will be lost.
@format
FIXME: xref keep-old
@end format

@node Extracting Specific Files ter, Extracting Directories ter, Extracting Files from an Archive ter, How to Extract Members from an Archive
@subsection Extracting Specific Files
@include docwarn.texi

To extract specific files, specify them using file name arguments.

In an example above, you created the archive file
@file{~/practice/records}, which contained the files @file{blues}, @file{folk} and
@file{jazz} in the @file{practice} directory.  If, for some reason, you were to
lose one of those text files (@samp{rm ~/practice/blues}), you could extract
it from the archive file.

First, change into the @file{practice} directory.  Then,

@itemize @bullet

@item
Invoke @code{tar} and specify the @value{extract} or @samp{--get}
operation.

@item
Specify the archive that the files will be extracted
from---@value{file}.

@item
Specify the files to extract, using file name arguments (if you
don't specify any files, @code{tar} extracts all the archive members)

@end itemize

@example
% tar --extract --file=records blues
@end example

If you list the contents of the directory, you will see that @file{blues}
is back:

@example
% ls
folk
jazz
records
blues
@end example

@node Extracting Directories ter,  , Extracting Specific Files ter, How to Extract Members from an Archive
@subsection Extracting Directories
@include docwarn.texi

To extract a directory and all the files it contains, use the
directory's name as a file name argument in conjunction with @samp{tar
+extract}.  Remember--@code{tar} stores and extracts file names relative to
the working directory.

In a previous example you stored the directory @file{~/practice} in the
archive file @file{~/music}.  If you delete the contents of @file{practice}, you
can restore them using @code{tar}.

First, change into the @file{practice} subdirectory (@samp{cd ~/practice}). 
Then, remove all the files in @file{~/practice} (@samp{rm *}).  If you list the
contents of the directory, you should now see that it is empty:

@example
%ls
%
@end example

Let's try to restore the contents of @file{practice} by extracting them from
the archive file @file{~/music}:

@example
tar --extract --file=~/music practice
@end example

Now, list the contents of @file{practice} again:

@example
%ls
practice
@end example

What happened to the files?  When you created @file{~/music}, your
working directory was your home directory.  When you extracted
@file{~/music}, your working directory was @file{~/practice}. @code{tar} stored the
files in @file{practice} relative to your home directory, and then extracted
them relative to @file{~/practice}.  The files are now in a new
subdirectory, called @file{~/practice/practice}.

To restore your files to their old positions, delete the new
directory and its contents, and then redo the example above with your
home directory as the working directory:

@example
% rm ~/practice/practice/*
% rmdir practice
% cd ..
% tar --extract --file=music practice
@end example

(@code{tar} will report that it is unable to create the directory
@file{~/practice} because it already exists.  This will not effect the
extraction of the other archive members.)

@node How to Add Files to Existing Archives, How to Delete Members from Archives, How to Extract Members from an Archive, Tutorial
@section How to Add Files to Existing Archives
@include docwarn.texi

If you want to add files to an existing archive, then don't use
@value{create}.  That will erase the archive and create a new one
in its place.  Instead, use @value{append}.  The command @samp{tar
--append --file=afiles.tar arbalest} would add the file @file{arbalest}
to the existing archive @file{afiles.tar}.  The archive must already
exist in order to use @value{append}.

As with @value{create}, the member names of the newly
added files will be the exact same as their names given on the
command line.  The @value{verbose} option will print
out the names of the files as they are written into the archive.

If you add a file to an archive using @value{append} with the
same name as an archive member already present in the archive, then the
old member is not deleted.  What does happen, however, is somewhat
complex.
@format
FIXME: xref Multiple Members with the Same Name.
@end format
If you want to replace an archive member, use @value{delete}
first, and then use @value{append}.

@format
FIXME: we want people to use the script for backups, so I an not going
FIXME: to use backups as an explanation in the tutorial.  (people can still
FIXME: do it if they really want to)
@end format

While you can use @code{tar} to create a new archive every time you want
to store a file, it is more sometimes efficient to add files to an
existing archive.

To add new files to an existing archive, use the @value{append} operation.  To add newer versions of archive members to
an archive, use the @value{update} operation.

While you can use @code{tar} to create an archive of an entire
directory or directory tree, it is more efficient when performing
backups to only archive those files which have been newly created or
changed since the last backup.

To add new files to an existing archive, or to add newer versions of
old files, you can use the @value{append}
operation, or the @value{update} operation.

@menu
* Append bis::                  
* Update bis::                  
* Concatenate bis::             
@end menu

@node Append bis, Update bis, How to Add Files to Existing Archives, How to Add Files to Existing Archives
@subsection Appending Files to an Archive
@include docwarn.texi

The simplest method of adding a file to an already existing archive is
the @value{append} operation, which writes the files
specified into the archive without regard to whether or not they are
already among the archived files.  When you use @value{append} you
must specify file name arguments, there is no default.  If you specify
a file that already exists in the archive another copy of the file
will be added to the end of the archive anyway.

In the previous examples you created a file called @file{rock} in the
practice directory which did not exist in either the archive file
@file{records}, in the practice directory, or the archive file
@file{music}, in the home directory.  To add @file{rock} to
@file{records}, you would, while in the practice directory:

@itemize @bullet
@item
Invoke @code{tar} and specify the operation to add a
file---@value{append}.
@item
Specify the name of the archive to which the file will be
added---@value{file}.
@item
Specify the name(s) of the file(s) to be added to the archive as the
file name argument(s)
@end itemize

@example
% tar --append --file=records rock
@end example

@noindent
If you now use the @value{list} operation, you will see that
@file{rock} has been added to the archive:

@example
% tar --list --file=records
blues
folk
jazz
rock
@end example

While all newly created files have now been added to @file{records},
it is still not current with respect to the contents of the practice
directory.  If you recall from the examples using @value{compare}
above, @file{blues} was changed after the archive @file{records} was
created.  It is simple, however, to use @value{append} to correct the
problem:

@example
% tar --append --verbose --file=records blues
blues
@end example

@noindent
Because you specified the @value{verbose} option, @code{tar} has
printed the name of the file being appended as it was acted on.  If
you now use @code{tar} with the @value{list} option specified to get
the contents of the archive, you will optain the following:

@example
% tar --list -f records
blues
folk
jazz
rock
blues
@end example

@noindent
The newest version of @file{blues} is now at the end of the archive.
Because files are extracted from archives in the order in which they
appear in the archive, and because extracted files are given the same
names in the file system as they are stored under in the archive, when
the files in @file{records} are extracted the newer version of
@file{blues} (which has the same name as the older) will overwrite the
version stored first.
@format
FIXME: xref Keep Old Files
@end format

@format
FIXME: --update wont take a directory argument if files that have been
FIXME: archived from that directory are now no longer in it.  (I assume
FIXME: because it looks in the archive first for the directory listing.)
FIXME: this is a bug
@end format

The simplest method of adding a file to an existing archive is
the @value{append} operation, which writes files into the archive
without regard to whether or not they are already archive members.
When you use @value{append} you must use file name arguments; there
is no default.  If you specify a file that is already stored in the
archive, @code{tar} adds another copy of the file to the archive.

If you have been following the previous examples, you should have a
text file called @file{~/practice/rock} which has not been stored in either
the archive file @file{~/practice/records}, or the archive file @file{~/music}. 
To add @file{rock} to @file{records}, first make @file{practice} the working directory
(@samp{cd practice}).  Then:

@itemize @bullet
@item
Invoke @code{tar} and specify the @value{append} operation.

@item
Specify the archive to which the file will be added---@value{file}.

@item
Specify the files to be added to the archive, using file name
arguments
@end itemize

For example:

@example
% tar --append --file=records rock
@end example

If you list the archive members in @file{records}, you will see that @file{rock}
has been added to the archive:

@example
% tar --list --file=records
blues
folk
jazz
rock
@end example

@format
FIXME: this should be some kind of node.
@end format

You can use @value{append} to keep archive members current with active
files.  Because @value{append} stores a file whether or not there is
already an archive member with the same file name, you can use
@value{append} to add newer versions of archive members to an archive. 
When you extract the file, only the version stored last will wind up in
the file system.  Because @value{extract} extracts files from an archive
in sequence, and overwrites files with the same name in the file
system, if a file name appears more than once in an archive the last
version of the file will overwrite the previous versions which have
just been extracted.

If you recall from the examples using @value{compare} above, @file{blues} was
changed after the archive @file{records} was created. It is simple, however,
to use @value{append} to add the new version of @file{blues} to @file{records}:

@example
% tar --append --verbose --file=records blues
blues
@end example

If you now list the contents of the archive, you will obtain the
following:

@example
% tar --list -f records
blues
folk
jazz
rock
blues
@end example

The newest version of @file{blues} is at the end of the archive.  When the
files in @file{records} are extracted, the newer version of @file{blues} (which
has the same name as the older) will overwrite the version stored
first.  When @value{extract} is finished, only the newer version of
@file{blues} is in the file system.
@format
FIXME: xref keep-old-files
@end format

@node Update bis, Concatenate bis, Append bis, How to Add Files to Existing Archives
@subsection Updating Files in an Archive
@include docwarn.texi

While the @value{append} option is useful for updating files in an
archive, to keep an archive current with @value{append} you must
first use the @value{compare} or @value{list} options to determine
what files have been changed (or be willing to waste space by adding
identical copies of archived files to the ends of archives).  It is
simpler to use the @value{update} operation, and let @code{tar} do
the work for you.

The @value{update} option causes @code{tar} to add files to the end of
an archive, just like the @value{append} option.  When you invoke
@code{tar} with the @value{update} option specified you must specify
file name arguments.  Unlike @value{append}, the @value{update} option
causes @code{tar} to check the archive to be updated to see if the
specified file is already stored.  If the file (or one with the same
name) is already in the archive, @code{tar} checks the modification
date of the file in the archive and compares it to the file of the
same name in the file system.  The file is only appended to the
archive if it is new or if its modification date has changed to a
later one.
@format
FIXME: xref After-Date
@end format

To see the @value{update} option at work, create a new file,
@file{classical}, in your practice directory, and add a line to the
file @file{blues}, using any text editor.  Then invoke @code{tar} with
the @value{update} operation and the @value{verbose} option specified,
using the names of all the files in the practice directory as file name
arguments:

@example
% tar --update --verbose --file=records blues folk rock classical
blues
classical
%
@end example

@noindent
Because we have specified verbose mode, @code{tar} prints out the
names of the files it is working on, which in this case are the names
of the files that needed to be updated.  If you now invoke @code{tar}
with the @value{list} operation specified, to generate a listing of
the files in the archive, you will see that @file{blues} and
@file{classical} have been added to its end.

[The reason @code{tar} does not overwrite the older file when updating
it is because writing to the middle of a section of tape is a difficult
process.  Tapes are not designed to go backward.  Even if they were,
imagine what would happen if the newer version were longer than the
older one.]

To keep archive members up to date with their counterparts of the
same name in the file system, use the @value{update} option. 
This adds a specified file to an archive if no file of that
name is already stored in the archive.  If there is already an archive
member with the same name, @code{tar} checks the modification date of the
archive member, and adds the file only if its modification date is
later.  If a file is stored in the archive but no longer exists under
the same name in the active file system, @code{tar} reports an error.

You could use the @value{append} option to keep an archive current, but
do so you would either have to use the @value{compare} and @value{list} options
to determine what files needed to be re-archived (which could waste a
lot of time), or you would have to be willing to add identical copies
of already archived files to the archive (which could waste a lot of
space).

You must use file name arguments with the @value{update} operation--if
you don't specify any files, @code{tar} won't act on any files.

To see the @value{update} option at work, create a new file,
@file{~/practice/classical}, and modify the file @file{~/practice/blues} (you can
use a text editor, such as Emacs, to do both these things).  Then, with
@file{practice} as your working directory, invoke @code{tar} with the
@value{update} option, using the
names of all the files in the practice directory as file name
arguments, and specifying the @value{verbose} option:

@example
% tar --update --verbose --file=records blues folk rock classical
blues
classical
%
@end example

Because you specified verbose mode, @code{tar} printed out the names of the
files it acted on.  If you now list the archive members of the archive,
(@samp{tar --list --file=records}), you will see that the file @file{classical} and
another version of the file @file{blues} have been added to @file{records}.

Note: When you update an archive, @code{tar} does not overwrite old
archive members when it stores newer versions of a file.  This is
because archive members appear in an archive in the order in which they
are stored, and some archive devices do not allow writing in the middle
of an archive.

@node Concatenate bis,  , Update bis, How to Add Files to Existing Archives
@subsection Concatenating Archives 
@include docwarn.texi

Rather than adding individual files onto the end of an archive, it may
be more convenient to add archives themselves onto the end of an
archive.  While it may seem intuitive to use @code{cat}, the utility
for adding files together, for this purpose, archives created by
@code{tar} incorporate an end of file marker which must be removed if
the concatenated archives are to be read properly as one archive
@format
FIXME: xref Ignore zeros.
@end format
To add archives to the end of another archive, therefore, you should
use the @value{concatenate} operation.

In earlier examples you created an archive file, @file{music}, in your
home directory.  You have, however, since changed the contents of the
@file{practice} directory which was stored in that archive.
@file{records}, the archive file in the @file{practice} directory, has
recently been updated, and contains a current version of the files in
@file{practice}.  Rather than update the contents of @file{music},
let's add @file{records} to it.

@itemize @bullet
@item
Change into the home directory (@samp{cd ..})
@item
Invoke @code{tar}, and specify the operation to add archives to the
end of another archive---@value{concatenate}.
@item
Specify the name of the archive file to be added to---@value{file}.
@item
Specify the file name arguments, which are, unusually, the names of
archive files.  Remember to include the directory name in the
file name, if the archive file is not in your working directory.
@end itemize

@example
% cd ..
% tar --concatenate --file=music practice/records
@end example

Rather than list the new contents of @file{music}, let's extract all the
files and see what happens.

To concatenate archive files, use the @value{concatenate} option.
This operation adds other archives to the end of an archive. While
it may seem intuitive to concatenate archives using @code{cat}, the
utility for adding files together, archive files which have been
``catted'' together cannot be read properly by @code{tar}.  Archive
files incorporate an end of file marker--if archives are concatenated
using @code{cat}, this marker will appear before the end of the
new archive.  This will interfere with operations on that archive.
@format
FIXME: xref ignore-zeros
@end format

In earlier examples, you stored the @file{~/practice} directory in an
archive file, @file{~/music}.  If you have been following the examples, you
have since changed the contents of the @file{~/practice} directory.  There
is a current version of the files in the @file{practice} directory, however,
stored in the archive file @file{~/practice/records}.

To store current versions of the files in @file{practice} in the archive
file @file{music}, you can use @value{concatenate} to add the archive file
@file{~/practice/records} to @file{music}.  First, make sure you are in your home
directory (@samp{cd ~}).  Then:

@itemize @bullet
@item
Invoke @code{tar}, and specify the @value{concatenate} operation.

@item
Specify the archive file to be added to---@value{file}.

@item
Specify the archives to be added, using file name arguments.  In
this case, the file name arguments are, unusually, the names of
archive files.  (Remember to include the path in the archive name,
if the archive file is not in your working directory.)
@end itemize

@example
% cd ~
% tar --concatenate --file=music practice/records
@end example

If you now list the contents of the @file{music}, you see it now contains
the archive members of @file{practice/records}:

@example
%tar --list --file=music
blues
folk
jazz
rock
blues
practice/blues
practice/folk
practice/jazz
practice/rock
practice/blues
practice/classical
@end example

@node How to Delete Members from Archives,  , How to Add Files to Existing Archives, Tutorial
@section How to Delete Members from Archives
@include docwarn.texi

You can delete members from an archive using @value{delete}.
Specify the name of the archive with @value{file}.  List the member
names of the members to be deleted.  (If you list no member names, then
nothing will be deleted.)  The @value{verbose} option will cause
@code{tar} to print the names of the members as they are deleted.  As
with @value{extract}, it is important that you give the exact
member names when using @samp{tar --delete}.  Use @value{list} to
find out the exact member names in an archive.
@format
FIXME: xref Listing Archives.
@end format

The @value{delete} option only works with archives stored on disk.
You cannot delete members from an archive stored on a tape.

In some instances, it may be advantageous to remove some files from an
archive stored on disk (it is never advantageous to delete files from
an archive stored on tape---the linear nature of tape storage makes
this action likely to scramble the archive).  You can use the
@value{delete} operation to remove files from an archive.  The names
of files to be removed must be specified to @code{tar} as file name
arguments.  All versions of the named file are removed from the
archive.  Execution of the @value{delete} operation can be very slow.

To delete all versions of the file @file{blues} from the archive
@file{records} in the @file{practice} directory, make sure you are in
that directory, and then,

@itemize @bullet
@item
List the contents of the archive file @file{records} (see above for
the steps involved) to insure that the file(s) you wish to delete are
stored in the archive.  (This step is optional)
@item
Invoke @code{tar} and specify the operation to delete files from an
archive (@value{delete})
@item
Specify the name of the archive file that the file(s) will be
deleted---@value{file}.
@item
Specify the name(s) of the file(s) to be deleted, as file name arguments
@item
List the contents of the archive file again---note that the files have
been removed.  (this step is also optional)
@end itemize

@example
% tar --list --file=records
blues
folk
jazz
% tar --delete --file=records blues
% tar --list --file=records
folk
jazz
% 
@end example

In some instances, you may want to remove some files from an archive
stored on disk

@quotation
@emph{Caution:} you should never delete files from an archive stored on
tape--because of the linear nature of tape storage, doing this is
likely to scramble the archive.
@end quotation

To remove archive members from an archive, use the @value{delete}
operation.  You must specify the names of files to be removed as
file name arguments.  All versions of the named file are removed from
the archive.

Execution of the @value{delete} operation can be very slow.

To delete all versions of the file @file{blues} from the archive
@file{records} in the @file{practice} directory, make sure you are in that
directory, and then:

@itemize @bullet
@item
List the contents of the archive file @file{records} (see above for the
steps involved) to insure that the file(s) you wish to delete are
stored in the archive.  (This step is optional)

@item
Invoke @code{tar} and specify the @value{delete} operation (@value{delete}).

@item
Specify the name of the archive file that the file(s) will be
deleted from---@value{file}.

@item
Specify the files to be deleted, using file name arguments.

@item
List the contents of the archive file again---note that the files
have been removed.  (this step is also optional)
@end itemize

@example
% tar --list --file=records
blues
folk
jazz
% tar --delete --file=records blues
% tar --list --file=records
folk
jazz
%
@end example

@node Invoking tar, Basic tar Operations, Tutorial, Top
@chapter Invoking GNU @code{tar}
@include docwarn.texi

@menu
* Synopsis::                    
* Option Styles::               
* Options::                     
@end menu

@node Synopsis, Option Styles, Invoking tar, Invoking tar
@section General Synopsis of @code{tar}

The usual way to invoke @code{tar} is:

@example
tar @var{option}@dots{} [@var{name}]@dots{}
@end example

You can actually type in arguments in any order, but in this manual the
options always precede the other arguments, to make examples easier
to understand.  Further, the option stating the main operation mode
(the @code{tar} @dfn{main command}) is usually given first.

There are surely many options to @code{tar}, and three different style
for writing them: mnemonic options, short options, and old options.
These styles are discussed below.  Some options make sense with any
main command, while others are meaningful only with particular main
commands.  One option should state the main command, all others are
truly optional.

Beware that @code{tar} options are case sensitive.  For example,
@value{List} or @value{List} options are not equivalent to
@value{list}, in fact, they do not even exist.  Options @samp{-T} and
@samp{-t} are different options, the first requires an argument for
stating the name of a file providing a list of @var{name}s, the second
does not require an argument and is another way to write @value{list}.

Each @var{name} in the synopsis above is interpreted as an archive
member name when the main command is one of @value{compare},
@value{delete}, @value{extract}, @value{list} or @value{update}.
For all other main commands, @var{name}s are interpreted as
the names of files (including directories) in the file system.
@code{tar} interprets relative file names as being relative to the
working directory.

@code{tar} will make all file names relative (by removing leading
@samp{/}s when archiving or restoring files), unless you specify
otherwise (using the @value{absolute-names} option).
@format
FIXME: xref File Name
Interpretation
@end format
, for more information about @value{absolute-names}.
@format
FIXME: yet another node name that is probably wrong.
@end format

The distinction between file names and archive member names is
especially important when shell globbing is used, and sometimes a
source of confusion for newcomers.  @dfn{Globbing} is the operation
by which @dfn{wildcard} characters, @samp{*} or @samp{?} for example,
are replaced and expanded into all existing files matching the given
pattern.  The problem is that shells may only glob using existing
files in the file system.  Only @code{tar} may glob on archive
members, so when needed, you must ensure that wildcard characters
reach @code{tar} without being interpreted by the shell first.
Using a backslash before @samp{*} or @samp{?}, or putting the whole
argument between quotes, is usually sufficient for this.

Even if @var{name}s are often specified on the command line, they
can also be read from a text file in the file system, using the
@value{files-from} option.

Each of the following subsection groups some options under a common
functionality.

You can use @code{tar} to store files in an archive, to extract them
from an archive, and to do other types of archive manipulation.  The
primary argument to @code{tar}, which is called the @dfn{operation},
specifies which action to take.  The other arguments to @code{tar}
are either @dfn{options}, which change the way @code{tar} performs
an operation, or @dfn{file names}, which specify the files @code{tar}
is to act on.  The typical @code{tar} command line syntax is:

@cindex exit status
@cindex return status
GNU @code{tar} returns only a few exit statuses.  I'm really
aiming simplicity in that area, for now.  If you are not using the
@value{compare} option, zero means that everything went well, besides
maybe innocuous warnings.  Nonzero means that something went wrong.
Right now, as of today, ``nonzero'' is almost always 2, except for
remote operations, where it may be 128.

@node Option Styles, Options, Synopsis, Invoking tar
@section Many Styles for Options

@menu
* Mnemonic Options::            
* Short Options::               
* Old Options::                 
* Mixing Styles::               
@end menu

@node Mnemonic Options, Short Options, Option Styles, Option Styles
@subsection Mnemonic Option Style

Each @var{option} has at least one mnemonic option name starting with
two dashes in a row, v.g. @value{list}.  The mnemonic option names are
more legible than the corresponding short or old option names, you may
prefer them if you highly praise clarity.  It sometimes happens that a
single mnemonic option has many different different names, which are
then synonymous.  In addition, mnemonic option names can be given unique
abbreviations.  For example, @samp{--cre} can be used in place of
@samp{--create} because there is no other mnemonic option which begins
with @samp{cre}.

Some options require an argument.  This is the case of the
@value{file} option, which tells the name of the
@code{tar} archive.  The argument of a mnemonic option is usually
given right after the option itself, and introduced by an equal sign.
For example, the @value{file} option is given the @file{archive.tar}
file as argument by using the notation @samp{--file=archive.tar} for
the mnemonic option.

Mnemonic options are meant to be obvious and easy to remember,
possibly more so than their corresponding short options, below.
For example:

@example
tar --create --verbose --block-size=20 --file=/dev/rmt0
@end example

@noindent
gives a fairly good set of hints about what the command does, even
for those not fully acquainted with @code{tar}.

@node Short Options, Old Options, Mnemonic Options, Option Styles
@subsection Short Option Style

Most options, but not all of them, also have a short option name
starting with a single dash, and followed by a single character,
v.g. @samp{-t}.  In fact, @samp{-t} is exactly the short option
name for the mnemonic option @value{list}, both having exactly the
same meaning.  The forms are absolutely identical in function.

The short option names are faster to type than mnemonic option names.
All along this manual, whenever a mnemonic option name is given, its
equivalent short option name follows between parentheses, if such a
short option name exists.

Short options which require arguments use the immediately following
argument, so it may be thought as being merely introduced right
after it, usually separate by white space.  It is also possible
to stick the argument right after the short option name, using no
intervening space.  So one might write @w{@samp{-f archive.tar}} or
@samp{-farchive.tar} instead of using @samp{--file=archive.tar}.  Both
@samp{--file=@var{archive-name}} and @w{@samp{-f @var{archive-name}}}
denote the option to give the archive a non-default name, which in the
example is @file{archive.tar}.  When the option is given separately,
its argument follows it, as is usual for Unix programs.  For example:

@example
tar -c -v -b 20 -f /dev/rmt0
@end example

Short options letters may be lumped together, but contrary to old
options, they do not necessarily have to.  When short options are
nevertheless coalesced, use a single dash for them all.  Only the last
one in such a set is allowed to have an argument.  (Clustering many
options, the last of which taking an argument, seems to be fairly
opaque writing to me.  I would even like that GNU @code{getopt} be
helpful enough to make this illegal.)

If you move short options in the command, be sure to move their
arguments along with them, if any.

@node Old Options, Mixing Styles, Short Options, Option Styles
@subsection Old Option Style
@include docwarn.texi

Old options are single letters not preceeded by any dash at all,
and appearing @emph{only} in the position immediately following the
@samp{tar} keyword in the command, after some white space.  The letter
of an old option is exactly the same letter as the corresponding
short option.  For example, the old option @samp{t} is the same
as the short option @samp{-t}, and consequently, the same as long
option @value{list}.

As far as we know, all @code{tar} programs, GNU and non-GNU, support
old options.  GNU @code{tar} supports them not only for historical
reasons, but also because many people are used to them.

All old options should be written as a single argument, without
separating spaces, by lumping together all letters specifying these
options.  This set of letters should be the first to appear on the
command line, after the @code{tar} program name; old options cannot
appear anywhere else.  Then, for any old option required an argument,
the argument should follow on the command line.  Arguments to the
options should appear in the same order as the letters to which
they correspond.  The @code{tar} command synopsis might be rewritten:

@example
tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}
@end example

@noindent
when old options are being used.

This command syntax is useful because it lets you type the single letter
forms of the operation and options as a single argument to @code{tar},
without writing preceding @samp{-}s or inserting spaces between letters.
@samp{tar cv} or @samp{tar -cv} are equivalent to @samp{tar -c -v}.

@cindex option syntax, traditional
For compatibility with Unix @code{tar}, the first argument can
contain an option letter (or a cluster of option letters) @emph{not}
introduced by a dash; for example, @samp{tar cv} specifies the option
@samp{-v} in addition to the command @samp{-c}.  When options that
need arguments are given together with the command, all the associated
arguments follow, in the same order as the options.  Thus, the example
above could also be written in the old style as follows:

@example
tar cvbf 20 /dev/rmt0
@end example

@noindent
Here @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
the argument of @samp{-f}.

On the other hand, this old style syntax makes it difficult to
match option letters with their corresponding arguments, and is
often confusing.  In the command @samp{tar cvbf 20 /dev/rmt0}, for
example, @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is
the argument for @samp{-f}, and @samp{-v} does not have a corresponding
argument.  Even using short options like in @samp{tar -c -v -b 20 -f
/dev/rmt0} is clearer, putting all arguments next to the option they
pertain to.

If you want to reorder the letters in the old option argument, be
sure to appropriately reorder any corresponding argument.

This old way of writing @code{tar} options can surprise even experienced
users.  For example, the two commands:

@example
tar cfz archive.tar.gz file
tar -cfz archive.tar.gz file
@end example

@noindent
are quite different.  The first example uses @file{archive.tar.gz} as
the value for option @samp{f} and recognizes the option @samp{z}.  The
second example, however, uses @file{z} as the value for option
@samp{f}---probably not what was intended.  (I find it quite inelegant
that @code{getopt} batches the remaining @samp{z} as the value for
@samp{f}.  I think that clarity dictates that clustering of option
letters, when some require arguments, should be diagnosed and
disallowed.  But compatibility with traditional systems dictates it.)
This second example could be corrected in many ways, among which:

@example
tar -czf archive.tar.gz file
tar -cf archive.tar.gz -z file
tar cf archive.tar.gz -z file
@end example

@node Mixing Styles,  , Old Options, Option Styles
@subsection Mixing Option Styles

All three styles may be intermixed in a single @code{tar} command,
as long as the rules for each style are fully respected.

In GNU @code{tar} up to 1.11.6, using old style options was cutting
out the possibility of using many options not having short forms.
Many users rightly expressed their frustration at fighting with the
current @code{tar} option decoder, so I changed it.  However, GNU @code{tar}
needs to be compatible with other @code{tar}s, in the things that other
@code{tar}s can do.  Short options should provide upward compatibility.
So, if the current option decoding raises incompatibilities, please
let me know.

Old style options and modern options may be mixed on a single call
to the @code{tar} program.  However, old style options should be
introduced in the first argument only; modern options may be given only
after all arguments to old style options have been collected.  If this
rule is not respected, a modern option might be falsely interpreted
as the value of the argument to one of the old style options.

For example, currently, all the following commands are wholly
equivalent, and illustrate many combinations and orderings of option
styles.

@example
tar --create --file=archive.tar
tar --create -f archive.tar
tar --create -farchive.tar
tar --file=archive.tar --create
tar --file=archive.tar -c
tar -c --file=archive.tar
tar -c -f archive.tar
tar -c -farchive.tar
tar -cf archive.tar
tar -cfarchive.tar
tar -f archive.tar --create
tar -f archive.tar -c
tar -farchive.tar --create
tar -farchive.tar -c
tar c --file=archive.tar
tar c -f archive.tar
tar c -farchive.tar
tar cf archive.tar
tar f archive.tar --create
tar f archive.tar -c
tar fc archive.tar
@end example

On the other hand, the following commands are @emph{not} equivalent to
the previous set:

@example
tar -f -c archive.tar
tar -fc archive.tar
tar -fcarchive.tar
tar -farchive.tarc
tar cfarchive.tar
@end example

@noindent
These last examples mean something completely different of what the user
might have intended.  The first four specify that the @code{tar}
archive would be a file named @samp{-c}, @samp{c}, @samp{carchive.tar} or
@samp{archive.tarc}, respectively.  The first two examples also specify a
single non-option, @var{name} argument having value @samp{archive.tar}.
The last example contains only old style option letters (repeating
option @samp{c} twice) and no argument value.

@node Options,  , Option Styles, Invoking tar
@section All Available Options
@include docwarn.texi

Options change the way @code{tar} performs an operation.

@table @samp
@item --absolute-names   

@item --after-date=@var{date}
Limit the operation to files changed after the given date.

@format
FIXME: xref File Exclusion
@end format
.

@item --block-size=@var{number}
Specify the blocking factor of an archive.
@format
FIXME: xref Blocking Factor
@end format
.

@item --compress
Specify a compressed archive.
@format
FIXME: xref Compressed Archives
@end format
.

@item --compress-block. 
Create a whole block sized compressed archive.
@format
FIXME: xref Compressed Archives
@end format
.

@item --confirmation
Solicit confirmation for each file.
@format
FIXME: xref Interactive Operation
@end format

@format
FIXME: --selective should be a synonym. 
@end format

@item --dereference
Treat a symbolic link as an alternate name for the file the link
points to.
@format
FIXME: xref Symbolic Links
@end format
.

@item --directory=@file{directory}
Change the working directory.
@format
FIXME: xref Changing Working Directory
@end format
.

@item --exclude=@var{pattern}
Exclude files which match the regular expression @var{pattern}.

@format
FIXME: xref File Exclusion
@end format
.

@item --exclude-from=@file{file}
Exclude files which match any of the regular expressions listed in
the file @file{file}.
@format
FIXME: xref File Exclusion
@end format
.

@item --file=@var{archive-name}
Name the archive.
@format
FIXME: xref Archive Name
@end format
).

@item --files-from=@file{file}
Read file name arguments from a file on the file system.

@format
FIXME: xref File Name Lists
@end format
. 

@item --ignore-umask
Set modes of extracted files to those recorded in the archive.

@format
FIXME: xref File Writing Options
@end format
.

@item --ignore-zeros
Ignore end-of-archive entries.
@format
FIXME: xref Archive Reading Options
@end format
.
@format
FIXME: this should be changed to --ignore-end 
@end format

@item --tape-length=@var{n}  (-L)
@format
FIXME: alternate way of doing multi archive, will go to that length and
FIXME: prompts for new tape, automatically turns on multi-volume.  this
FIXME: needs to be written into main body as well
@end format

@item --info-script=@var{program-file}
Create a multi-volume archive via a script.
@format
FIXME: xref Multi-Volume Archives
@end format
.

@item --interactive
Ask for confirmation before performing any operation on a file or
archive member.

@item --keep-old-files
Prevent overwriting during extraction.
@format
FIXME: xref File Writing Options
@end format
.

@item --label=@var{archive-label}
Include an archive-label in the archive being created.
@format
FIXME: xref Archive
Label
@end format
.

@item --modification-time
Set the modification time of extracted files to the time they were
extracted.
@format
FIXME: xref File Writing Options
@end format
.

@item --multi-volume
Specify a multi-volume archive.
@format
FIXME: xref Multi-Volume Archives
@end format
.

@item --newer=@var{date}
Limit the operation to files changed after the given date.

@format
FIXME: xref File Exclusion
@end format
.

@item --newer-mtime=@var{date}
Limit the operation to files modified after the given date.
@format
FIXME: xref File
Exclusion
@end format
.

@item --old
Create an old format archive.
@format
FIXME: xref Old Style File Information
@end format
.
@format
FIXME: did we agree this should go away as a synonym?
@end format

@item --old-archive
Create an old format archive.
@format
FIXME: xref Old Style File Information
@end format
.

@item --one-file-system
Prevent @code{tar} from crossing file system boundaries when
archiving.
@format
FIXME: xref File Exclusion
@end format
.

@item --portability
Create an old format archive.
@format
FIXME: xref Old Style File Information
@end format
.
@format
FIXME: was portability, may still need to be changed
@end format

@item --preserve-order
Help process large lists of file names on machines with small amounts of
memory.
@format
FIXME: xref Archive Reading Options
@end format
.

@item --preserve-permission
Set modes of extracted files to those recorded in the archive.

@format
FIXME: xref File Writing Options
@end format
.

@item --read-full-blocks
Read an archive with a smaller than specified block size or which
contains incomplete blocks.
@format
FIXME: xref Archive Reading Options
@end format
).
@format
FIXME: should be --partial-blocks (!)
@end format
 
@item --record-number
Print the record number where a message is generated.

@format
FIXME: xref Additional Information
@end format
.

@item --same-order
Help process large lists of file names on machines with small amounts of
memory.
@format
FIXME: xref Archive Reading Options
@end format
.

@item --same-permission
Set the modes of extracted files to those recorded in the archive.

@format
FIXME: xref File Writing Options
@end format
.

@item --sparse
Archive sparse files sparsely.
@format
FIXME: xref Sparse Files
@end format
.

@item --starting-file=@var{file name}
Begin reading in the middle of an archive.
@format
FIXME: xref Scarce Disk Space
@end format
.

@item --to-stdout
Write files to the standard output.
@format
FIXME: xref File Writing Options
@end format
.

@item --uncompress
Specifdo  a compressed archive.
@format
FIXME: xref Compressed Archives
@end format
.

@item -V @var{archive-label}
Include an archive-label in the archive being created.
@format
FIXME: xref Archive
Label
@end format
.
@format
FIXME: was --volume
@end format

@item --verbose
Print the names of files or archive members as they are being
operated on.
@format
FIXME: xref Additional Information
@end format
.

@item --verify
Check for discrepancies in the archive immediately after it is
written.
@format
FIXME: xref Write Verification
@end format
.

@item -B 
Read an archive with a smaller than specified block size or which
contains incomplete blocks.
@format
FIXME: xref Archive Reading Options
@end format
).

@item -K @var{file name}
Begin reading in the middle of an archive.
@format
FIXME: xref Scarce Disk Space
@end format
.

@item -M
Specify a multi-volume archive.
@format
FIXME: xref Multi-Volume Archives
@end format
.

@item -N @var{date}
Limit operation to files changed after the given date.
@format
FIXME: xref File Exclusion
@end format
.

@item -O
Write files to the standard output.
@format
FIXME: xref File Writing Options
@end format
.

@format
FIXME: - P is absolute names, add when resolved.
@end format

@item -R 
Print the record number where a message is generated.

@format
FIXME: xref Additional Information
@end format
.

@item -S
Archive sparse files sparsely.
@format
FIXME: xref Sparse Files
@end format
.

@item -T @var{file}
Read file name arguments from a file on the file system.

@format
FIXME: xref File Name Lists
@end format
. 

@item -W
Check for discrepancies in the archive immediately after it is
written.
@format
FIXME: xref Write Verification
@end format
.

@item -Z
Specify a compressed archive.
@format
FIXME: xref Compressed Archives
@end format
.

@item -b @var{number}
Specify the blocking factor of an archive.
@format
FIXME: xref Blocking Factor
@end format
.

@item -f @var{archive-name}
Name the archive.
@format
FIXME: xref Archive Name
@end format
).

@item -h
Treat a symbolic link as an alternate name for the file the link
points to.
@format
FIXME: xref Symbolic Links
@end format
.

@item -i
Ignore end-of-archive entries.
@format
FIXME: xref Archive Reading Options
@end format
.

@item -k 
Prevent overwriting during extraction.
@format
FIXME: xref File Writing Options
@end format
.

@item -l
Prevent @code{tar} from crossing file system boundaries when
archiving.
@format
FIXME: xref File Exclusion
@end format
.

@item -m
Set the modification time of extracted files to the time they were
extracted.
@format
FIXME: xref File Writing Options
@end format
.

@item -o
Create an old format archive.
@format
FIXME: xref Old Style File Information
@end format
.

@item -p
Set the modes of extracted files to those recorded in the archive.

@format
FIXME: xref File Writing Options
@end format
.

@item -s
Help process large lists of file names on machines with small amounts of
memory.
@format
FIXME: xref Archive Reading Options
@end format
.

@item -v
Print the names of files or archive members they are being operated
on.
@format
FIXME: xref Additional Information
@end format
.

@item -w
@format
FIXME: see --interactive.
@end format

@item -z
Specify a compressed archive.
@format
FIXME: xref Compressed Archives
@end format
.

@item -z -z
Create a whole block sized compressed archive.
@format
FIXME: xref Compressed Archives
@end format
.
@format
FIXME: I would rather this were -Z.  it is the only double letter short
FIXME: form.
@end format

@item -C @file{directory}
Change the working directory.
@format
FIXME: xref Changing Working Directory
@end format
.

@item -F @var{program-file}
Create a multi-volume archive via a script.
@format
FIXME: xref Multi-Volume Archives
@end format
.

@item -X @file{file}
Exclude files which match any of the regular expressions listed in
the file @file{file}.
@format
FIXME: xref File Exclusion
@end format
.
@end table

@menu
* Device Options::              
* Blocking Options::            
* Classification Options::      
@end menu

@node Device Options, Blocking Options, Options, Options
@subsection Device selection and switching
@include docwarn.texi

@table @code

@item -f [@var{hostname}:]@var{file}
@itemx --file=[@var{hostname}:]@var{file}
Use archive file or device @var{file} on @var{hostname}.
@format
FIXME: xref Device
@end format
.

@item --force-local
Archive file is local even if it contains a colon.
@format
FIXME: xref Device
@end format
.

@item --rsh-command=@var{command}
Use remote @var{command} instead of @code{rsh}.
@format
FIXME: xref Device
@end format
.

@item -[0-7][lmh]
Specify drive and density.
@format
FIXME: xref Device
@end format
.

@item -M
@itemx --multi-volume
Create/list/extract multi-volume archive.
@format
FIXME: xref Multi
@end format
.

@item -L @var{num}
@itemx --tape-length=@var{num}
Change tape after writing @var{num} x 1024 bytes.
@format
FIXME: xref Multi
@end format
.

@item -F @var{file}
@itemx --info-script=@var{file}
@itemx --new-volume-script=@var{file}
Execute @file{file} at end of each tape.  This implies
@value{multi-volume}).
@format
FIXME: xref Multi
@end format
.

@end table

@node Blocking Options, Classification Options, Device Options, Options
@subsection Device blocking
@include docwarn.texi

@table @code

@item -b @var{blocks}
@itemx --block-size=@var{blocks}
Set block size to @math{@var{blocks} * 512} bytes.
@format
FIXME: xref Blocking
@end format
.

@item --block-compress
Block the output of compression for tapes.
@format
FIXME: xref Blocking
@end format
.

@item -i
@itemx --ignore-zeros
Ignore blocks of zeros in archive (means EOF).
@format
FIXME: xref Blocking
@end format
.

@item -B
@itemx --read-full-blocks
Reblock as we read (for reading 4.2BSD pipes).
@format
FIXME: xref Blocking
@end format
.

@end table

@node Classification Options,  , Blocking Options, Options
@subsection Old classification of options
@include docwarn.texi

The information here is to be revised and merged into the remainder of
this document, possibly altering its structure.

Options could be regrouped in three categories:

@table @asis
@item General Options
Options that are always meaningful.
@item Creation Options
Options for creating or updating an archive.
@item Extraction Options
Options for listing or extracting files.
@end table

Here are the options that are always meaningful.

@table @asis
@item @samp{-B @var{number}}, @samp{--block-size @var{number}}
@item @samp{-f @var{filename}}, @samp{--file @var{filename}}
@item @samp{-C @var{dir}}, @samp{--directory @var{dir}}
@item @samp{-M}, @samp{--multi-volume}
@item @samp{-N @var{date}}, @samp{--after-date @var{date}}
@item @samp{-R}, @value{record-number}
@item @samp{-T @var{filename}}, @samp{--files-from @var{filename}}
@item @samp{-v}, @value{verbose}
@item @samp{-w}, @samp{--interactive}
@item @samp{-X @var{file}}, @samp{--exclude @var{file}}
@item @samp{-z}, @samp{-Z}, @samp{--compress}, @samp{--uncompress}
@end table

Here are the options for creating or updating an archive.
These options are used to control which files @code{tar} puts
in an archive, or to control the format the archive is written
in
@format
FIXME: ref Format
@end format
.  Except as noted elsewhere, these options are
useful with the @value{create}, @value{append}, @value{update},
@value{concatenate}, and @value{delete} commands.  Also note that
the @value{read-full-block} option
@format
FIXME: (pxref Extraction Options),
@end format
is also useful with the @value{append}, @value{update},
@value{concatenate}, and @value{delete} commands.

@table @asis
@item @samp{-G}, @samp{--incremental}
@item @samp{-h}, @value{dereference}
@item @samp{-l}, @samp{--one-file-system}
@item @samp{-o}, @value{old-archive}
@item @samp{--old}, @samp{--portability}
@item @samp{-S}, @samp{--sparse}
@item @samp{-V NAME}, @samp{--volume NAME}
@item @samp{-W}, @samp{--verify}
@end table

Here are the options for listing or extracting files.  The options
in this section are meaningful with the @value{extract} command.
Unless otherwise stated, they are also meaningful with the @value{list}
command.

@table @asis
@item @samp{-B}, @samp{--read-full-blocks}
@item @samp{-G}, @samp{--incremental}
@item @samp{-i}, @samp{--ignore-zeros}
@item @samp{-k}, @samp{--keep-old-files}
@item @samp{-K @var{filename}}, @samp{--starting-file @var{filename}}
@item @samp{-m}, @samp{--modification-time}
@item @samp{-O}, @samp{--to-stdout}
@item @samp{-p}, @samp{--same-permissions}, @samp{--preserve-permissions}
@item @samp{-P}, @value{absolute-names}
@item @samp{-s}, @samp{--same-order}, @samp{--preserve-order}
@item @samp{--preserve}
@end table

@node Basic tar Operations, Specifying Names to tar, Invoking tar, Top
@chapter Basic @code{tar} Operations
@include docwarn.texi

This chapter describes the basic operations supported by the @code{tar}
program.  A given invocation of @code{tar} will do exactly one of these
operations.

An archive member in normally extracted into a file with the same name
as the archive member.  However, you can use the @value{to-stdout} to
cause @code{tar} to write extracted archive members to standard output.
If you extract multiple members, they appear on standard output
concatenated, in the order they are found in the archive.

The @value{create} operation writes a new archive, and the
@value{extract} operation reads files from an archive and writes them
into the file system.  You can use other @code{tar} operations to
write new information into an existing archive (adding files to it,
adding another archive to it, or deleting files from it), and you can
read a list of the files in an archive without extracting it using the
@value{list} operation.

The primary argument to @code{tar} is the @dfn{operation}, which specifies
what @code{tar} does.  @code{tar} can be used to:

@itemize @bullet
@item
Add files to an existing archive---@value{append}.

@item
Compare files in an archive with files in the file
system---@value{compare} or @samp{--diff}.

@item
Add archives to another archive---@value{concatenate}.

@item
Create an archive---@value{create}.

@item
Delete files from an archive---@value{delete}.

@item
Extract files from an archive---@value{extract} or @samp{--get}.

@item
List the files in an archive---@value{list}.

@item
Update an archive by appending newer versions of already stored
files---@value{update}.
@end itemize


@format
FIXME: xref Reading and Writing
@end format
, for more information about these
operations.

@dfn{Option} arguments to @code{tar} change details of the operation, such as
archive format, archive name, or level of user interaction. You can
specify more than one option.  All options are optional.

@dfn{File Name} arguments specify which files (including directory
files) to archive, extract, delete or otherwise operate on.

If you don't use any file name arguments, @value{append}, @value{update} and
@value{delete} will do nothing.  The other operations of @code{tar} will act on
defaults.

When you use a file name argument to specify a directory file, @code{tar}
acts on all the files in that directory, including sub-directories.

You must give exactly one option from the following list to @code{tar}.  This
option specifies the basic operation for @code{tar} to perform.

@table @samp

@item --create
@item -c
Create a new archive

@item --catenate
@item --concatenate
@item -A
Add the contents of one or more archives to another archive

@item --append
@item -a
Add files to an existing archive

@item --list
@item -t
List the members in an archive

@item --delete
Delete members from an archive

@item --extract
@item --get
@item -x
Extract members from an archive

@item --compare
@item --diff
@item -d
Compare members in an archive with files in the file system

@item --update
@item -u
Update an archive by appending newer versions of already stored files
@end table

The remaining options to @code{tar} change details of the operation,
such as archive format, archive name, or level of user interaction.
You can specify more than one option.

The remaining arguments are interpreted either as file names or as
member names, depending on the basic operation @code{tar} is
performing.  For @value{append} and @value{create} these arguments
specify the names of files (which must already exist) to place in the
archive.  For the remaining operation types, the additional arguments
specify archive members to compare, delete, extract, list, or update.
When naming archive members, you must give the exact name of the member
in the archive, as it is printed by @value{list}.  When naming
files, the normal file name rules apply.

If you don't use any additional arguments, @value{append},
@value{concatenate}, and @value{delete} will do nothing.  Naturally,
@value{create} will make an empty archive if given no files to add.
The other operations of @code{tar} (@value{list}, @value{extract},
@value{compare}, and @value{update}) will act on the entire contents
of the archive.

If you give the name of a directory as either a file name or a member
name, then @code{tar} acts recursively on all the files and directories
beneath that directory.  For example, the name @file{/} identifies all
the files in the filesystem to @code{tar}.

The operation argument to @code{tar} specifies which action you want to
take.

@table @samp
@item -A
Adds copies of an archive or archives to the end of another archive.

@item -c
Creates a new archive.  

@item -d
Compares files in the archive with their counterparts in the file
system, and reports differences in file size, mode, owner,
modification date and contents.

@item -r
Adds files to the end of the archive.  

@item -t
Prints a list of the contents of the archive.

@item -x
Reads files from the archive and writes them into the active file
system.

@item -u
Adds files to the end of the archive, but only if they are newer than
their counterparts already in the archive, or if they do not already
exist in the archive.

@item --catenate
Adds copies of an archive or archives to the end of another archive.

@item --append
Adds files to the end of the archive.  

@item --append
Adds files to the end of the archive.  

@item --catenate
Adds copies of an archive or archives to the end of another archive.

@item --compare
Compares files in the archive with their counterparts in the file
system, and reports differences in file size, mode, owner,
modification date and contents.

@item --concatenate
Adds copies of an archive or archives to the end of another archive.

@item --create
Creates a new archive.  

@item --delete
Deletes files from the archive.  All versions of the files are deleted.

@item --diff
Compares files in the archive with their counterparts in the file
system, and reports differences in file size, mode, owner,
modification date and contents.

@item --extract
Reads files from the archive and writes them into the active file
system.

@item --get
Reads files from the archive and writes them into the active file
system.

@item --list
Prints a list of the contents of the archive.

@item --update
Adds files to the end of the archive, but only if they are newer than
their counterparts already in the archive, or if they do not already
exist in the archive.

@item --version
Prints the version number of the @code{tar} program to the standard
error.
@end table

The program @code{tar} can create an archive, extract files from an
archive, modify an archive, or list an archive's contents.  Each time
you run @code{tar}, you must give a @dfn{command} to specify which one
of these things you want to do.

The command must always be in the first argument to @code{tar}.
This argument can also contain options (
@format
FIXME: pxref Invoking tar
@end format
).
For compatibility with Unix @code{tar}, the first argument is
always treated as containing command and option letters even if it
doesn't start with @samp{-}.  Thus, @samp{tar c} is equivalent to
@w{@samp{tar -c}:} both of them specify the @value{create} command
to create an archive.

In addition, a set of long-named options are provided which can be used
instead of or intermixed with the single-letter flags.  The long-named
options are meant to be easy to remember and logical, while the single
letter flags may not always be.  Long-named options begin with
@samp{--}.

Arguments after the first are either options, if they start with
@samp{-} or @samp{--}, or files to operate on.

The file names that you give as arguments are the files that @code{tar}
will act on---for example, they are the files to put in the archive, or
the files to extract from it.  If you don't give any file name
arguments, the default depends on which command you used.  Some commands
use all relevant files; some commands have no default and will report an
error if you don't specify files.

@cindex directory arguments
If a file name argument actually names a directory, then that directory
and all files and subdirectories (recursively) in it are used.

Here is a list of the @code{tar} commands:

@table @code

@item -c
@itemx --create
Create a new archive.

This command tells @code{tar} to create a new archive that contains
the file(s) specified on the command line.  If you don't specify
files, all the files in the current directory are used.

If the archive file already exists, it is overwritten; the old contents
are lost.

@item -x
@itemx --extract
@itemx --get
Extract files from an archive.

This command causes @code{tar} to extract the specified files from
the archive.  If no file names are given, all the files in the archive
will be extracted.

@item -t
@itemx --list
List the contents of an archive.

This command causes @code{tar} to display a list of the files in
the archive.  If you specify file names, only the files that you
specify will be mentioned (but each of them is mentioned only if it
appears in the archive).

@item -d
@itemx --diff
@itemx --compare
Find differences between an archive and the corresponding online files.

This command causes @code{tar} to compare the archive with the files
in the file system.  It will report differences in file size, mode,
owner, and contents.  If a file exists in the archive, but not in
the file system, @code{tar} will report this.

If you specify file names, those files are compared with the tape and
they must all exist in the archive.  If you don't specify files, all
the files in the archive are compared.

@item -r
@itemx --append
Append files to the end of an archive.

This command causes @code{tar} to add the specified file(s) to the end
of the archive.  This assumes that the archive file already exists
and is in the proper format (which probably means it was created
previously with the @code{tar} program).  If the archive is not in a
format that @code{tar} understands, the results will be unpredictable.

You must specify the files to be used; there is no default.

@item -u
@itemx --update
Only append files newer than the version in an archive.

This command causes @code{tar} to add the specified files to the end
of the archive, like @value{append}, but only when a file doesn't
already exist in the archive or is newer than the version in the
archive (the last-modification time is compared).  Adding files to
the end of an archive can be very slow.

You must specify the files to be used; there is no default.

@item -A
@itemx --catenate
@itemx --concatenate
Append existing archives to another archive.

This command is used for concatenating several archive files into one
big archive file.  The files to operate on should all be archive files.
They are all appended to the end of the archive file which @code{tar}
works on.  (The other files are not changed).

You might be tempted to use @code{cat} for this, but it won't ordinarily
work.  A @code{tar} archive contains data which indicates the end of the
archive, so appended material is ignored.  This command works because it
removes the end-of-archive markers from the middle of the result.

@item --delete
Delete from the archive (not on tapes!).

This command causes @code{tar} to delete the specified files from the
archive.  This command is extremely slow.  Warning: Use of this command
on archives stored on magnetic tape may result in a scrambled archive.
There is no safe way (except for completely re-writing the archive)
to delete files from a magnetic tape.

@end table

The program @code{tar} can create an archive, extract files from an
archive, modify an archive, or list an archive's contents.  Each time
you run @code{tar}, you must give a @dfn{command} to specify which one
of these things you want to do.

The command must always be in the first argument to @code{tar}.
This argument can also contain options (
@format
FIXME: pxref Invoking tar
@end format
).
For compatibility with Unix @code{tar}, the first argument is
always treated as containing command and option letters even if it
doesn't start with @samp{-}.  Thus, @samp{tar c} is equivalent to
@w{@samp{tar -c}:} both of them specify the @value{create} command
to create an archive.

In addition, a set of long-named options are provided which can be used
instead of or intermixed with the single-letter flags.  The long-named
options are meant to be easy to remember and logical, while the single
letter flags may not always be.  Long-named options begin with
@samp{--}.

Arguments after the first are either options, if they start with
@samp{-} or @samp{--}, or files to operate on.

The file names that you give as arguments are the files that @code{tar}
will act on---for example, they are the files to put in the archive, or
the files to extract from it.  If you don't give any file name
arguments, the default depends on which command you used.  Some commands
use all relevant files; some commands have no default and will report an
error if you don't specify files.

@cindex directory arguments
If a file name argument actually names a directory, then that directory
and all files and subdirectories (recursively) in it are used.

Modifying Archives
@cindex Modifying archives

Once an archive is created, you can add new archive members to it, add
the contents of another archive, add newer versions of members already
stored, or delete archive members already stored.  

To find out what files are already stored in an archive, use @samp{tar
--list --file=@var{archive-name}}.
@format
FIXME: xref Listing Contents
@end format
.

@menu
* Creating a New Archive::      
* Adding to an Existing Archive::  
* Updating an Archive::         
* Combining Archives::          
* Removing Archive Members::    
* Listing Archive Members::     
* Extracting Archive Members::  
* Comparing Archives Members with Files::  
* Matching Format Parameters::  
@end menu

@node Creating a New Archive, Adding to an Existing Archive, Basic tar Operations, Basic tar Operations
@section Creating a New Archive
@include docwarn.texi

The @value{create} option causes @code{tar} to create a new
archive.  The files to be archived are then named on the command line.
Each file will be added to the archive with a member name exactly the
same as the name given on the command line.  (When you give an absolute
file name @code{tar} actually modifies it slightly,
@format
FIXME: ref Absolute
Names
@end format
.)  If you list no files to be archived, then an empty archive is
created. 

If there are two many files to conveniently list on the command line,
you can list the names in a file, and @code{tar} will read that file.

@format
FIXME: xref Reading Names from a File
@end format
.

If you name a directory, then @code{tar} will archive not only the
directory, but all its contents, recursively.  For example, if you name
@file{/}, then @code{tar} will archive the entire filesystem.

Do not use the option to add files to an existing archive; it will
delete the archive and write a new one.  Use @value{append} instead.
(
@format
FIXME: xref Adding to an Existing Archive
@end format
.)

There are various ways of causing @code{tar} to skip over some files,
and not archive them.
@format
FIXME: xref Specifying Names to tar
@end format
.

@format
FIXME: operations should probably have examples, not tables.
@end format

@cindex Writing new archives
@cindex Archive creation

To create an archive, use @value{create}.  To name the archive,
use @samp{--file=@var{archive-name}} in conjunction with the
@value{create} operation (
@format
FIXME: pxref Archive Name
@end format
).  If you do not name
the archive, @code{tar} uses the value of the environment variable
@code{TAPE} as the file name for the archive, or, if that is not
available, @code{tar} uses a default archive name, usually that for tape
unit zero.
@format
FIXME: xref Archive Name
@end format
, for more information about specifying
an archive name.

The following example creates an archive named @file{stooges},
containing the files @file{larry}, @file{moe} and @file{curley}:

@example
tar --create --file=stooges larry moe curley
@end example

If you specify a directory name as a file name argument, @code{tar}
will archive all the files in that directory.  The following example
creates an archive named @file{hail/hail/fredonia}, containing the
contents of the directory @file{marx}:

@example
tar --create --file=hail/hail/fredonia marx
@end example

If you don't specify files to put in the archive, @code{tar} archives
all the files in the working directory.  The following example creates
an archive named @file{home} containing all the files in the working
directory:

@example
tar --create --file=home
@end example


@format
FIXME: xref File Name Lists
@end format
, for other ways to specify files to archive.

Note: In the example above, an archive containing all the files in the
working directory is being written to the working directory.  GNU
@code{tar} stores files in the working directory in an archive which
is itself in the working directory without falling into an infinite
loop.  Other versions of @code{tar} may fall into this trap.

@node Adding to an Existing Archive, Updating an Archive, Creating a New Archive, Basic tar Operations
@section Adding to an Existing Archive
@include docwarn.texi

The @value{append} option will case @code{tar} to add new
files to an existing archive.  It interprets file names and member names
in exactly the same manner as @value{create}.  Nothing happens if you
don't list any names.

This option never deletes members.  If a new member is added under the
same name as an existing member, then both will be in the archive, with
the new member after the old one.  For information on how this affects
reading the archive,
@format
FIXME: ref Multiple Members with the Same Name
@end format
.

This operation cannot be performed on some tape drives, unfortunately,
due to deficiencies in the formats thoes tape drives use.

@cindex Adding files to an archive
@cindex Updating an archive

To add files to an archive, use @value{append}.  The archive to
be added to must already exist and be in proper archive format (which
normally means it was created previously using @code{tar}).  If the
archive was created with a different block size than now specified,
@code{tar} will report an error (
@format
FIXME: pxref Blocking Factor
@end format
).  If the
archive is not a valid @code{tar} archive, the results will be
unpredictable.  You cannot add files to a compressed archive, however
you can add files to the last volume of a multi-volume archive.

@format
FIXME: xref Matching Format Parameters
@end format
.

The following example adds the file @file{shemp} to the archive
@file{stooges} created above:

@example
tar --append --file=stooges shemp
@end example

You must specify the files to be added; there is no default.

@value{update} acts like @value{append}, but does not add
files to the archive if there is already a file entry with that name
in the archive that has the same modification time.  

Both @value{update} and @value{append} work by adding to the end of
the archive.  When you extract a file from the archive, only the
version stored last will wind up in the file system.  Because
@value{extract} extracts files from an archive in sequence, and
overwrites files with the same name in the file system, if a file name
appears more than once in an archive the last version of the file will
overwrite the previous versions which have just been extracted.  You
should avoid storing older versions of a file later in the archive.

Note:  @value{update} is not suitable for performing backups, because
it doesn't change directory content entries, and because it lengthens
the archive every time it is used.  
@format
FIXME: xref to scripted backup, listed incremental, for info on backups.
@end format

@node Updating an Archive, Combining Archives, Adding to an Existing Archive, Basic tar Operations
@section Updating an Archive
@include docwarn.texi

The @value{update} option updates a @code{tar} archive by comparing
the date of the specified archive members against the date of
the file with the same name.  If the file has been modified more
recently than the archive member, then the archive member is deleted
(as with @value{delete}) and then the file is added to the archive
(as with @value{append}).  On media where the @value{delete} option
cannot be performed (such as magnetic tapes), the @value{update}
option similarly fails.

If no archive members are named (either on the command line or via
@value{files-from}), then the entire archive is processed in this
manner. 

@node Combining Archives, Removing Archive Members, Updating an Archive, Basic tar Operations
@section Combining Archives
@include docwarn.texi

The @value{concatenate} or @value{catenate} option causes @code{tar}
to add the contents of several archives to an existing archive.

Name the archives to be catenated on the command line.  (Nothing happens
if you don't list any.)  The members, and their member names, will be
copied verbatim from those archives.  If this causes multiple members to
have the same name, it does not delete either; all the members with the
same name coexist.  For information on how this affects reading the
archive,
@format
FIXME: ref Multiple Members with the Same Name
@end format
.

You must use this option to concatenate archives.  If you just combine
them with @code{cat}, the result will not be a valid @code{tar} format
archive.

This operation cannot be performed on some tape drives, unfortunately,
due to deficiencies in the formats thoes tape drives use.

@cindex Adding archives to an archive
@cindex Concatenating Archives

To append copies of an archive or archives to the end of another
archive, use @value{concatenate}.  The source and target archives
must already exist and have been created using compatable format
parameters (
@format
FIXME: pxref Matching Format Parameters
@end format
).

@code{tar} will stop reading an archive if it encounters an
end-of-archive marker.  The @code{cat} utility does not remove
end-of-archive markers, and is therefore unsuitable for concatenating
archives.  @value{concatenate} removes the end-of-archive marker
from the target archive before each new archive is appended.
@format
FIXME: xref ignore-zeros
@end format

You must specify the source archives using @value{file} (
@format
FIXME: pxref Archive
Name
@end format
).  If you do not specify the target archive , @code{tar} uses
the value of the environment variable @code{TAPE}, or, if this has
not been set, the default archive name.

The following example adds the contents of the archive
@file{hail/hail/fredonia} to the archive @file{stooges} (both archives
were created in examples above):

@example
tar --catenate --file=stooges hail/hail/fredonia
@end example

If you need to retrieve files from an archive that was added to using
the @code{cat} utility, use the @value{ignore-zeros} option
(
@format
FIXME: pxref Archive Reading Options
@end format
).

@node Removing Archive Members, Listing Archive Members, Combining Archives, Basic tar Operations
@section Removing Archive Members
@include docwarn.texi

You can use the @value{delete} option to remove members from an
archive.  Name the members on the command line to be deleted.  This
option will rewrite the archive; because of this, it does not work on
tape drives.  If you list no members to be deleted, nothing happens.

@cindex Deleting files from an archive
@cindex Removing files from an archive

To delete archive members from an archive, use @value{delete}.
You must specify the file names of the members to be deleted.  All
archive members with the specified file names will be removed from the
archive.

The following example removes the file @file{curley} from the archive
@file{stooges}:

@example
tar --delete --file=stooges curley
@end example

You can only use @value{delete} on an archive if the archive
device allows you to write to any point on the media.

@quotation
@strong{Warning:} Don't try to delete an archive member from a
magnetic tape, lest you scramble the archive.  There is no safe way
(except by completely re-writing the archive) to delete files from
most kinds of magnetic tape.
@end quotation

@format
FIXME: how about automatic detection of archive media?  give error
FIXME: unless the archive device is either an ordinary file or different
FIXME: input and output (--file=-).
@end format

@node Listing Archive Members, Extracting Archive Members, Removing Archive Members, Basic tar Operations
@section Listing Archive Members
@include docwarn.texi

The @value{list} option will list the names of members of
the archive.  Name the members to be listed on the command line (to
modify the way these names are interpreted,
@format
FIXME: pxref Specifying Names to
tar
@end format
).  If you name no members, then @value{list} will list the
names of all the members of the archive.

To see more than just the names of the members, use the @value{verbose}
option to cause @code{tar} to print out a listing similar to that of
@samp{ls -l}.

Listing the Contents of an Archive
@cindex Names of the files in an archive
@cindex Archive contents, list of
@cindex Archive members, list of

@value{list} prints a list of the file names of the archive
members on the standard output.  If you specify @var{file name}
arguments on the command line (or using the @value{files-from} option,

@format
FIXME: pxref File Name Lists
@end format
), only the files you specify will be listed,
and only if they exist in the archive.  Files not specified will be
ignored, unless they are under a specific directory.

If you include the @value{verbose} option, @code{tar} prints an
@samp{ls -l} type listing for the archive.
@format
FIXME: pxref Additional
Information
@end format
, for a description of the @value{verbose} option.

If the blocking factor of the archive differs from the default,
@code{tar} reports this.
@format
FIXME: xref Blocking Factor
@end format
.


@format
FIXME: xref Archive Reading Options
@end format
for a list of options which can be used
to modify @value{list}'s operation.  

This example prints a list of the archive members of the archive
@file{stooges}:

@example
tar --list --file=stooges
@end example

@noindent
@code{tar} responds:

@example
larry
moe
shemp
marx/julius
marx/alexander
marx/karl
@end example

This example generates a verbose list of the archive members of the
archive file @file{dwarves}, which has a blocking factor of two:

@example
tar --list -v --file=blocks
@end example

@noindent
@code{tar} responds:

@example
tar: Blocksize = 2 records
-rw------- ringo/user 42 May   1 13:29 1990 .bashful
-rw-rw-rw- ringo/user 42 Oct   4 13:29 1990 doc
-rw-rw-rw- ringo/user 42 Jul  20 18:01 1969 dopey
-rw-rw---- ringo/user 42 Nov  26 13:42 1963 grumpy
-rw-rw-rw- ringo/user 42 May   5 13:29 1990 happy
-rw-rw-rw- ringo/user 42 May   1 12:00 1868 sleepy
-rw-rw-rw- ringo/user 42 Jul   4 17:29 1776 sneezy
@end example

@node Extracting Archive Members, Comparing Archives Members with Files, Listing Archive Members, Basic tar Operations
@section Extracting Archive Members
@include docwarn.texi

Use @value{extract} or @samp{--get} to extract members
from an archive.  For each member named (or for the entire archive if no
members are named) on the command line---or with @value{files-from}---the
a file is created with the contents of the archive member.  The name of
the file is the same as the member name.

Various options cause @code{tar} to extract more than just file
contents, such as the owner, the permissions, the modification date, and
so forth.  

@format
FIXME: begin
@end format
The @value{same-permissions} or @samp{--preserve-permissions} options
cause @code{tar} to cause the new file to have the same permissions as
the original file did when it was placed in the archive.  Without this
option, the current @code{umask} is used to affect the permissions.

When extrating, @code{tar} normally sets the modification time of the
file to the value recorded in the archive.  The
@value{modification-time} option causes @code{tar} to omit doing this.
@format
FIXME: end
@end format

@cindex Extraction
@cindex Retrieving files from an archive
@cindex Resurrecting files from an archive

To read archive members from the archive and write them into the file
system, use @value{extract}.  The archive itself is left
unchanged.

If you do not specify the files to extract, @code{tar} extracts all
the files in the archive.  If you specify the name of a directory as a
file name argument, @code{tar} will extract all files which have been
stored as part of that directory.  If a file was stored with a
directory name as part of its file name, and that directory does not
exist under the working directory when the file is extracted,
@code{tar} will create the directory.
@format
FIXME: xref Selecting Archive
Members
@end format
, for information on specifying files to extract.

The following example shows the extraction of the archive
@file{stooges} into an empty directory:

@example
tar --extract --file=stooges
@end example

@noindent
Generating a listing of the directory (@samp{ls}) produces:

@example
larry
moe
shemp
marx
@end example

@noindent
The subdirectory @file{marx} contains the files @file{julius},
@file{alexander} and @file{karl}.

If you wanted to just extract the files in the subdirectory
@file{marx}, you could specify that directory as a file name argument
in conjunction with the @value{extract} operation:

@example
tar --extract --file=stooges marx
@end example

@quotation
@strong{Warning:} Extraction can overwrite files in the file system.
To avoid losing files in the file system when extracting files from
the archive with the same name, use the @value{keep-old-files} option
(
@format
FIXME: pxref File Writing Options
@end format
).
@end quotation

If the archive was created using @value{block-size}, @value{compress}
or @value{multi-volume}, you must specify those format options again
when extracting files from the archive (
@format
FIXME: pxref Format Variations
@end format
).

@menu
* Archive Reading Options::     
* File Writing Options::        
* Scarce Disk Space::           
@end menu

@node Archive Reading Options, File Writing Options, Extracting Archive Members, Extracting Archive Members
@subsection Options to Help Read Archives
@cindex Options when reading archives
@cindex Reading incomplete blocks
@cindex Blocks, incomplete
@cindex End-of-archive entries, ignoring
@cindex Ignoring end-of-archive entries
@cindex Large lists of file names on small machines
@cindex Small memory 
@cindex Running out of space
@include docwarn.texi

@format
FIXME: each option wants its own node.  summary after menu
@end format

Normally, @code{tar} will request data in full block increments from
an archive storage device.  If the device cannot return a full block,
@code{tar} will report an error.  However, some devices do not always
return full blocks, or do not require the last block of an archive to
be padded out to the next block boundary.  To keep reading until you
obtain a full block, or to accept an incomplete block if it contains
an end-of-archive marker, specify the @value{read-full-blocks} option
in conjunction with the @value{extract} or @value{list} operations.

@format
FIXME: xref Listing Contents
@end format
.

The @value{read-full-blocks} option is turned on by default when
@code{tar} reads an archive from standard input, or from a remote
machine.  This is because on BSD Unix systems, attempting to read a
pipe returns however much happens to be in the pipe, even if it is
less than was requested.  If this option were not enabled, @code{tar}
would fail as soon as it read an incomplete block from the pipe.

If you're not sure of the blocking factor of an archive, you
can read the archive by specifying @value{read-full-blocks} and
@value{block-size}, using a blocking factor larger than what the
archive uses.  This lets you avoid having to determine the blocking
factor of an archive.
@format
FIXME: xref Blocking Factor
@end format
.

@table @samp
@item --read-full-blocks
@item -B 
Use in conjunction with @value{extract} to read an archive which
contains incomplete blocks, or one which has a blocking factor less
than the one specified.
@end table

Normally @code{tar} stops reading when it encounters a block of zeros
between file entries (which usually indicates the end of the archive).
@value{ignore-zeros} allows @code{tar} to completely read an archive
which contains a block of zeros before the end (i.e.@: a damaged
archive, or one which was created by @code{cat}-ing several archives
together).

The @value{ignore-zeros} option is turned off by default because many
versions of @code{tar} write garbage after the end-of-archive entry,
since that part of the media is never supposed to be read.  GNU
@code{tar} does not write after the end of an archive, but seeks to
maintain compatablity among archiving utilities.

@table @samp
@item --ignore-zeros
@itemx -i
To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
encountered while reading an archive.  Use in conjunction with
@value{extract} or @value{list}.
@end table

If you are using a machine with a small amount of memory, and you
need to process large list of file names, you can reduce the amount
of space @code{tar} needs to process the list.  To do so, specify the
@value{same-order} option and provide an ordered list of file names.
This option tells @code{tar} that the @var{name} arguments provided
on the command line, or read from a file using the @value{files-from}
option, are listed in the same order as the files in the archive.

You can create a file containing an ordered list of files in the
archive by storing the output produced by @samp{tar --list
--file=@var{archive-name}}.
@format
FIXME: xref Listing Contents
@end format
, for information
on the @value{list} operation.

This option is probably never needed on modern computer systems.

@table @samp
@item --same-order
@itemx --preserve-order
@itemx -s
To process large lists of file names on machines with small amounts of
memory.  Use in conjunction with @value{compare},
@value{list}
or @value{extract}.
@end table

@format
FIXME: we don't need/want --preserve to exist any more
@end format

@node File Writing Options, Scarce Disk Space, Archive Reading Options, Extracting Archive Members
@subsection Changing How @code{tar} Writes Files 
@format
FIXME: find a better title
@end format
@cindex Overwriting old files, prevention
@cindex Protecting old files
@cindex Modification times of extracted files
@cindex Permissions of extracted files
@cindex Modes of extracted files
@cindex Writing extracted files to standard output
@cindex Standard output, writing extracted files to
@include docwarn.texi

Normally, @code{tar} writes extracted files into the file system
without regard to the files already on the system---files with the
same name as archive members are overwritten.  To prevent @code{tar}
from extracting an archive member from an archive, if doing so will
overwrite a file in the file system, use @value{keep-old-files} in
conjunction with the @value{extract} operation.  When this option is
specified, @code{tar} reports an error stating the name of the files
in conflict, instead of writing the file from the archive.

@table @samp
@item --keep-old files
@itemx -k 
Prevents @code{tar} from overwriting files in the file system during
extraction. 
@end table

Normally, @code{tar} sets the modification times of extracted files to
the modification times recorded for the files in the archive, but
limits the permissions of extracted files by the current @code{umask}
setting.

To set the modification times of extracted files to the time when
the files were extracted, use the @value{modification-time} option in
conjunction with @value{extract}.

@table @samp
@item --modification-time
@itemx -m
Sets the modification time of extracted archive members to the time
they were extracted, not the time recorded for them in the archive.
Use in conjunction with @value{extract}.
@end table

To set the modes (access permissions) of extracted files to those
recorded for those files in the archive, use the
@value{same-persmissions} option in conjunction with the
@value{extract} operation.
@format
FIXME: mib --- should be aliased to ignore-umask.  
@end format

@table @samp
@item --preserve-permission
@itemx --same-permission
@itemx --ignore-umask
@itemx -p
Set modes of extracted archive members to those recorded in the
archive, instead of current umask settings.  Use in conjunction with
@value{extract}. 
@end table

@format
FIXME: following paragraph needs to be rewritten: why doesnt' this cat
FIXME: files together, why is this useful.  is it really useful with
FIXME: more than one file?
@end format
To write the files extracted to the standard output, instead of
creating the files on the file system, use @value{to-stdout} in
conjunction with @value{extract}.  This option is useful if you
are extracting files to send them through a pipe, and do not need to
preserve them in the file system.

@table @samp
@item --to-stdout
@itemx -O
Writes files to the standard output.  Used in conjunction with
@value{extract}. 
@end table

@format
FIXME: why would you want to do such a thing, how are files separated on
FIXME: the standard output? is this useful with more that one file?  are
FIXME: pipes the real reason?
@end format

@node Scarce Disk Space,  , File Writing Options, Extracting Archive Members
@subsection Recovering From Scarce Disk Space
@cindex Middle of the archive, starting in the
@cindex Running out of space during extraction
@cindex Disk space, running out of
@cindex Space on the disk, recovering from lack of
@include docwarn.texi

If a previous attempt to extract files failed due to lack of disk
space, you can use @value{starting-file} to start extracting only
after file @var{name} when extracting files from the archive.
This assumes, of course, that there is now free space, or that you
are now extracting into a different file system.

@table @samp
@item --starting-file=@var{file name}
@itemx -K @var{file name}
Starts an operation in the middle of an archive.  Use in conjunction
with @value{extract} or @value{list}.
@end table

If you notice you are running out of disk space during an extraction
operation, you can also suspend @code{tar}, remove unnecessary files
from the file system, and then restart the same @code{tar} operation.
In this case, @value{starting-file} is not necessary. 

@format
FIXME: xref --incremental,  xref --interactive,  xref --exclude
@end format

@node Comparing Archives Members with Files, Matching Format Parameters, Extracting Archive Members, Basic tar Operations
@section Comparing Archives Members with Files
@include docwarn.texi

The @value{compare} or @samp{--diff} option compares the contents of
the specified archive members against the files with the same names,
and reports its findings.  If no members are named on the command line,
or through @value{files-from}, then the entire archive is so compared.

@node Matching Format Parameters,  , Comparing Archives Members with Files, Basic tar Operations
@section Matching the Format Parameters
@include docwarn.texi

Some format parameters must be taken into consideration when modifying
an archive:

Compressed archives cannot be modified.  

You have to specify the block size of the archive when modifying an
archive with a non-default block size.

Multi-volume archives can be modified like any other archive.  To add
files to a multi-volume archive, you need to only mount the last
volume of the archive media (and new volumes, if needed).  For all
other operations, you need to use the entire archive.  

If a multi-volume archive was labeled using @value{label}
(
@format
FIXME: pxref Archive Label
@end format
) when it was created, @code{tar} will
not automatically label volumes which are added later.  To label
subsequent volumes, specify @value{label} again in conjunction with
the @value{append}, @value{update} or @value{concatenate} operation.
@cindex Labelling multi-volume archives
@format
FIXME: example
@end format

@format
FIXME: xref somewhere, for more information about format parameters.
@end format

@node Specifying Names to tar, Being Careful, Basic tar Operations, Top
@chapter Specifying Names to @code{tar}
@include docwarn.texi

@menu
* Changing the Archive Name::   
* Characteristics::             
* Selection Options::           
@end menu

@node Changing the Archive Name, Characteristics, Specifying Names to tar, Specifying Names to tar
@section Changing the Archive Name
@include docwarn.texi

By default, @code{tar} uses an archive file name compiled in when
@code{tar} was built.  Usually this refers to some physical tape drive
on the machine.  Often, the installer of @code{tar} didn't set the
default to anything meaningful at all.

As a result, most uses of @code{tar} need to tell @code{tar} where
to find (or create) the archive.  The @value{file} option selects
another file to use as the archive.

If the archive file name includes a colon (@samp{:}), then it is assumed
to be a file on another machine.  If the archive file is
@samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
host @var{host}.  The remote host is accessed using the @code{rsh}
program, with a username of @var{user}.  If the username is omitted
(along with the @samp{@@} sign), then your user name will be used.
(This is the normal @code{rsh} behavior.)  It is necessary for the
remote machine, in addition to permitting your @code{rsh} access, to
have the @file{/usr/ucb/rmt} program installed.  If you need to use a
file whose name includes a colon, then the remote tape drive behavior
can be inhibited by using the @value{force-local} option.

If the file name you give to @value{file} is a single dash (@samp{-}),
then @code{tar} will read the archive from (or write it to) standard
input (or standard output).

The Name of an Archive 
@cindex Naming an archive
@cindex Archive Name
@cindex Directing output
@cindex Where is the archive?

An archive can be saved as a file in the file system, sent through
a pipe or over a network, or written to an I/O device such as a
tape or disk drive.  To specify the name of the archive, use the
@value{file} option.

An archive name can be the name of an ordinary file or the name of an
I/O device.  @code{tar} always needs an archive name---if you do not
specify an archive name, the archive name comes from the environment
variable @code{TAPE} or, if that variable is not specified, a default
archive name, which is usually the name of tape unit zero (ie.
/dev/tu00).

If you use @file{-} as an @var{archive-name}, @code{tar} reads the
archive from standard input (when listing or extracting files), or
writes it to standard output (when creating an archive).  If you use
@file{-} as an @var{archive-name} when modifying an archive,
@code{tar} reads the original archive from its standard input and
writes the entire new archive to its standard output.  

@format
FIXME: does standard input and output redirection work with all
FIXME: operations?  
FIXME: need example for standard input and output (screen and keyboard?)
@end format

@cindex Standard input and output
@cindex tar to standard input and output

To specify an archive file on a device attached to a remote machine,
use the following:

@example
--file=@var{hostname}:/@var{dev}/@var{file name}
@end example

@noindent
@code{tar} will complete the remote connection, if possible, and
prompt you for a username and password.  If you use
@samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @code{tar}
will complete the remote connection, if possible, using your username
as the username on the remote machine.  

@format
FIXME: is this clear?
@end format

@table @samp
@item --file=@var{archive-name}
@itemx -f @var{archive-name}
Names the archive to create or operate on.  Use in conjunction with
any operation.
@end table

Selecting Archive Members
@cindex Specifying files to act on
@cindex Specifying archive members

@dfn{File Name arguments} specify which files in the file system
@code{tar} operates on, when creating or adding to an archive, or
which archive members @code{tar} operates on, when reading or
deleting from an archive.  (
@format
FIXME: pxref Reading and Writing
@end format
.)

To specify file names, you can include them as the last arguments on
the command line, as follows:
@example
tar @var{operation} [@var{option1} @var{option2} ..] [@var{file name-1} @var{file name-2} ...]
@end example

If you specify a directory name as a file name argument, all the files
in that directory are operated on by @code{tar}. 

If you do not specify files when @code{tar} is invoked, @code{tar}
operates on all the non-directory files in the working directory (if
the operation is @value{create}), all the archive members in the
archive (if a read operation is specified), or does nothing (if any
other operation is specified).

When specifying the names of files or members to @code{tar}, it by
default takes the names of the files from the command line.  There are
other ways, however, to specify file or member names, or to modify the
manner in which @code{tar} selects the files or members upon which to
operate.  In general, these methods work both for specifying the names
of files and archive members.

@node Characteristics, Selection Options, Changing the Archive Name, Specifying Names to tar
@section Selecting Files by Characteristic
@cindex File names, excluding files by
@cindex Excluding files by name and pattern
@cindex Excluding files by file system
@cindex File system boundaries, not crossing
@cindex Excluding file by age
@cindex Modification time, excluding files by
@cindex Age, excluding files by

To avoid crossing file system boundaries when archiving parts of a
directory tree, use @value{one-file-system}.  This option only affects
files that are archived because they are in a directory that is being
archived; files explicitly named on the command line are archived
regardless of where they reside.

This option is useful for making full or incremental archival backups
of a file system.

If this option is used in conjunction with @value{verbose}, files that
are excluded are mentioned by name on the standard error.

@table @samp
@item --one-file-system
@itemx -l
Prevents @code{tar} from crossing file system boundaries when
archiving.  Use in conjunction with any write operation.
@end table

To avoid operating on files whose names match a particular pattern,
use the @value{exclude} or @value{exclude-from} options.

When you specify the @value{exclude} option, @code{tar} ignores
files which match the @var{pattern}, which can be a single file
name or a more complex expression.  Thus, if you invoke @code{tar}
with @samp{tar --create --exclude=*.o}, no files whose names end in
@file{.o} are included in the archive.
@format
FIXME: what other things can you use besides "*"?
@end format

@value{exclude-from} acts like @value{exclude}, but specifies a file
@var{file} containing a list of patterns.  @code{tar} ignores files
with names that fit any of these patterns.

You can use either option more than once in a single command.

@table @samp
@item --exclude=@var{pattern}
Causes @code{tar} to ignore files that match the @var{pattern}.

@item --exclude-from=@var{file}
Causes @code{tar} to ignore files that match the patterns listed in
@var{file}.
@end table
@format
FIXME: --exclude-from used to be "--exclude", --exclude didn't used to
FIXME: exist.
@end format

To operate only on files with modification or status-change times
after a particular date, use @value{after-date}.  You can use this
option with @value{create} or @value{append} to insure only new files
are archived, or with @value{extract} to insure only recent files
are resurrected.
@format
FIXME: or --newer @var{date}
@end format

@value{newer-mtime} acts like @value{after-date} but tests just the
modification times of the files, ignoring status-change times.

@format
FIXME: need example of --newer-mtime with quoted argument
@end format
Remember that the entire date argument should be quoted if it contains
any spaces.

@strong{Please Note:} @value{after-date} and @value{newer-mtime} should
not be used for incremental backups.  Some files (such as those in
renamed directories) are not selected up properly by these options.
@format
FIXME: xref to incremental backup chapter when node name is decided.
@end format

@table @samp
@item --after-date=@var{date}
@itemx --newer=@var{date}
@itemx -N @var{date}
Acts on files only if their modification or inode-changed times are
later than @var{date}.  Use in conjunction with any operation.
@item --newer-mtime=@var{date}
Acts like @value{after-date}, but only looks at modification times.
@end table

@format
FIXME: following is the getdate date format --- needs to be re-written,
FIXME: made a sub-node:
@end format

Time/Date Formats Accepted by getdate
(omitting obscure constructions)

The input consists of one or more of: time zone day date year
in any order.

Those in turn consist of (`|' and `/' mean `or', `[]' means `optional'):

time: H am/pm | H:M [am/pm] | H:M:S [am/pm]
zone: timezone-name | timezone-name dst
day: day-name | day-name, | N day-name
date: M/D | M/D/Y | month-name D | month-name D, Y | D month-name | D month-name Y
year: Y

am can also be a.m., pm can also be p.m.
case and spaces around punctuation are not significant.
@format
FIXME: month and day names can be abbreviated.
@end format

@menu
* Reading Names from a File::   
* Excluding Some Files::        
* Operating Only on New Files::  
* Crossing Filesystem Boundaries::  
@end menu

@node Reading Names from a File, Excluding Some Files, Characteristics, Characteristics
@subsection Reading Names from a File
@include docwarn.texi

Instead of giving the names of files or archive members on the
command line, you can put the names into a file, and then use the
@value{files-from} option to @code{tar}.  Give the name of the
file which contains the list as the argument to @value{files-from}.
The file names should be separated by newlines in the list.  If you
give a single dash as a file name for @value{files-from}, that is,
you specify @samp{--files-from=-} (@samp{-T -}), then the file names
are read from standard input.

If you want to specify names that might contain newlines, use the
@value{null} option.  Then, the file names should be separated
by NUL characters (ASCII 000) instead of newlines.  In addition,
the @value{null} option turns off the @value{directory} option
(
@format
FIXME: pxref Changing Directory
@end format
).

Reading a List of File Names from a File
@cindex Lists of file names
@cindex File Name arguments, alternatives
@include docwarn.texi

To read file names from a file on the file system, instead of from
the command line, use the @value{files-from} option.  If you specify
@samp{-} as @var{file}, the file names are read from standard
input.  Note that using both @samp{--files-from=-} (@samp{-T -})
and @samp{--file=-} (@samp{-f -}) in the same command will not work
unless the operation is @value{create}.
@format
FIXME: xref Archive Name
@end format
, for an
explanation of the @value{file} option.

@table @samp
@item --files-from=@var{file}
@itemx -T @var{file}
Reads file name arguments from a file on the file system, instead of
from the command line.  Use in conjunction with any operation.
@end table

@node Excluding Some Files, Operating Only on New Files, Reading Names from a File, Characteristics
@subsection Excluding Some Files
@include docwarn.texi

The @value{exclude} option will prevent any file or member which
matches the regular expression @var{pattern} from being operated on.
For example, if you want to create an archive with all the contents of
@file{/tmp} except the file @file{/tmp/foo}, you can use the command
@samp{tar --create --file=arch.tar --exclude=foo}.

If there are many files you want to exclude, you can use
the @value{exclude-from} option.  This works just like the
@value{files-from} option: specify the name of a file as
@var{exclude-list} which contains the list of patterns you want
to exclude.


@format
FIXME: xref Regular Expressions
@end format
for more information on the syntax and
meaning of regular expressions.

@node Operating Only on New Files, Crossing Filesystem Boundaries, Excluding Some Files, Characteristics
@subsection Operating Only on New Files
@include docwarn.texi

The @value{after-date} or @samp{--newer=@var{date}} limits @code{tar}
to only operating on files which have been modified after the
date specified.  (For more information on how to specify a date,

@format
FIXME: xref Date Formats
@end format
.)  A file is considered to have changed if the
contents have been modified, or if the owner, permissions, and so
forth, have been changed.

If you only want @code{tar} make the date comparison on the basis
of the actual contents of the file's modification, then use the
@value{newer-mtime} option.

You should never use this option for making incremental dumps.  To learn
how to use @code{tar} to make backups,
@format
FIXME: ref Making Backups
@end format
.

@node Crossing Filesystem Boundaries,  , Operating Only on New Files, Characteristics
@subsection Crossing Filesystem Boundaries
@include docwarn.texi

The @value{one-file-system} option causes @code{tar} to modify its
normal behavior in archiving the contents of directories.  If a file in
a directory is not on the same filesystem as the directory itself
(because it is a mounted filesystem in its own right), then @code{tar}
will not archive that file, or (if it is a directory itself) anything
beneath it.  

This does not necessarily limit @code{tar} to only archiving the
contents of a single filesystem, because all files named on the
command line, or through the @value{files-from} option, will always
be archived.

@node Selection Options,  , Characteristics, Specifying Names to tar
@section Local file selection
@include docwarn.texi

Local file selection

@table @code

@item -C @var{dir}
@itemx --directory @var{dir}
Change to directory @var{dir}.

This option causes @code{tar} to change into the directory @var{dir}
before continuing.  This option can be interspersed with the files
@code{tar} is to work on.  For example,

@example
tar -c iggy ziggy -C baz melvin
@end example

@noindent
will place the files @samp{iggy} and @samp{ziggy} from the current
directory on the tape, followed by the file @file{melvin} from the
directory @file{baz}.  This option is especially useful when you
have several widely separated files that you want to store in the
same directory in the archive.

Here, the file @file{melvin} is recorded in the archive under the
precise name @file{melvin}, @emph{not} @file{baz/melvin}.  Thus, the
archive will contain three files that all appear to have come from the
same directory; if the archive is extracted with plain @w{@samp{tar
-x}}, all three files will be created in the current directory.

Contrast this with the command:

@example
tar -c iggy ziggy bar/melvin
@end example

@noindent
which records the third file in the archive under the name
@file{bar/melvin} so that, if plain @samp{tar -x} is used, the third
file will be created in a subdirectory named @file{bar}.

Suppose that, without changing your current directory, you want
to call @code{tar} to dump files from @file{/users/ctd/dipp} say.
Then @value{directory} is for you.  You could do things like:

@example
tar cfC archive.tar /users/ctd/dipp .
@end example

@noindent
(the @file{.} means the current directory, once the @value{directory}
obeyed).

Some people might want some option to extract everything from an
archive in the current directory, ignore directory structure in
the archive.  This is so rarely proper that I doubt such an option
would be really useful.  It would only help getting around improper
@code{tar} usage, it might even encourage improper usage.  In general,
@value{directory} might be used to produce archives with a cleaner
structure in the first place.

@item -T @var{filename}
@itemx --files-from=@var{filename}
Get names to extract or create from file @var{filename}.

Instead of taking the list of files to work on from the command line,
the list of files to work on is read from the file @var{filename}.
If @var{filename} is given as @samp{-}, the list is read from
standard input.  Note that using both @samp{-T -} and @samp{-f -}
will not work unless you are using the @value{create} command.

This is typically useful when you have generated the list of files to
archive with @code{find}.

@item --null
This option causes @value{files-from} to read file names terminated
by a @key{NUL} instead of a newline, so files whose names contain
newlines can be archived using @value{files-from}.  The @value{null}
option is just like the one in GNU @code{xargs} and @code{cpio},
and is useful with the @samp{-print0} predicate of GNU @code{find}.
In @code{tar}, @value{null} also causes @value{directory} options to
be treated as file names to archive, in case there are any files out
there called @file{-C}.

@item --exclude=@var{file}
Exclude file @var{file}.

@item -X @var{file}
@itemx --exclude-from=@var{file}
Exclude files listed in @var{file}.

This option causes @code{tar} to read a list of regular expressions (in
shell wildcard syntax), one per line, from @var{file}; @code{tar} will
ignore files matching those regular expressions.  Thus if @code{tar} is
called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains
a single line @file{*.o}, no files whose names end in @file{.o} will be
added to the archive.  Multiple @value{exclude} options may be given.

@item -P
@itemx --absolute-names
Do not strip leading @kbd{/}s from file names.

By default, GNU @code{tar} drops a leading @samp{/} on input or output.
This option turns off this behavior; it's equivalent to changing to the
root directory before running @code{tar} (except it also turns off the
usual warning message).

@item -l
@itemx --one-file-system
Stay in local filesystem when creating archive.

This option causes @code{tar} to not cross filesystem boundaries when
archiving parts of a directory tree.  This option only affects files
that are archived because they are in a directory that is archived;
files named on the command line are archived regardless, and they
can be from various file systems.

This option is useful for making full or incremental archival backups
of a filesystem, as with the Unix @code{dump} command.

Files skipped due to this option are mentioned on standard error.

@item -K @var{name}
@itemx --starting-file=@var{name}
Begin at file @var{name} in the archive.

The @value{starting-file} option causes @code{tar} to begin
extracting or listing the archive with the file @var{filename}, and
to consider only the files starting at that point in the archive.
This is useful if a previous attempt to extract files failed when
it reached @var{filename} due to lack of free space.  (Assuming, of
course, that there is now free space, or that you are now extracting
into a different file system.)

@item -N @var{date}
@itemx --newer=@var{date}
@itemx --after-date=@var{date}
Only store files newer than @var{date}.

This option causes @code{tar} to only work on files whose modification
or inode-changed times are newer than the @var{date} given.  The main
use is for creating an archive; then only new files are written.
If extracting, only newer files are extracted.

Remember that the entire date argument must be quoted if it contains any
spaces.

The date is parsed using @code{getdate}.

@end table

Changing the Names of Members when Archiving

@menu
* Changing Directory::          
* Absolute File Names::         
@end menu

@node Changing Directory, Absolute File Names, Selection Options, Selection Options
@subsection Changing Directory
@include docwarn.texi

The @value{directory} option causes @code{tar} to change its current
working directory to @var{directory}.  Unlike most options, this
one is processed at the point it occurs within the list of files to
be processed.  Consider the following command:
@example
tar --create --file=foo.tar -C /etc passwd hosts -C /lib libc.a
@end example

This command will place the files @file{/etc/passwd}, @file{/etc/hosts},
and @file{/lib/libc.a} into the archive.  However, the names of the
archive members will be exactly what they were on the command line:
@file{passwd}, @file{hosts}, and @file{libc.a}.  The @value{directory}
option is frequently used to make the archive independent of the
original name of the directory holding the files.

Note that @value{directory} options are interpreted consecutively.
If @value{directory} option specifies a relative file name, it is
interpreted relative to the then current directory, which might not
be the same as the original current working directory of @code{tar},
due to a previous @value{directory} option.

When using @value{files-from} (
@format
FIXME: pxref Reading Names from a File
@end format
), you
can put @samp{-C} options in the file list.  Unfortunately, you cannot
put @samp{--directory} options in the file list.  (This interpretation
can be disabled by using the @value{null} option.)

Changing the Working Directory Within a List of File Names
@cindex Directory, changing in mid-stream
@cindex Working directory, specifying
@include docwarn.texi

To change working directory in the middle of a list of file
names, either on the command line or in a file specified using
@value{files-from}, use @value{directory}.  This will change the
working directory to the directory @var{directory} after that point
in the list.  For example,

@example 
tar --create iggy ziggy --directory=baz melvin
@end example

@noindent
will place the files @file{iggy} and @file{ziggy} from the current
directory into the archive, followed by the file @file{melvin} from
the directory @file{baz}.  This option is especially useful when you
have several widely separated files that you want to store in the same
directory in the archive.

Note that the file @file{melvin} is recorded in the archive under the
precise name @file{melvin}, @emph{not} @file{baz/melvin}.  Thus, the
archive will contain three files that all appear to have come from the
same directory; if the archive is extracted with plain @samp{tar
--extract}, all three files will be written in the current directory.

Contrast this with the command

@example
tar -c iggy ziggy bar/melvin
@end example

@noindent
which records the third file in the archive under the name
@file{bar/melvin} so that, if the archive is extracted using @samp{tar
--extract}, the third file will be written in a subdirectory named
@file{bar}.

@table @samp
@item --directory=@file{directory}
@itemx -C @file{directory}
Changes the working directory.  
@end table

@format
FIXME: need to test how extract deals with this, and add an example
@end format

@node Absolute File Names,  , Changing Directory, Selection Options
@subsection Absolute File Names
@include docwarn.texi

When @code{tar} extracts archive members from an archive, it strips any
leading slashes (@samp{/}) from the member name.  This causes absolute
member names in the archive to be treated as relative file names.  This
allows you to have such members extracted wherever you want, instead of
being restricted to extracting the member in the exact directory named
in the archive.  For example, if the archive member has the name
@file{/etc/passwd}, @code{tar} will extract it as if the name were
really @file{etc/passwd}.

Other @code{tar} programs do not do this.  As a result, if you create an
archive whose member names start with a slash, they will be difficult
for other people with an inferior @code{tar} program to use.  Therefore,
GNU @code{tar} also strips leading slashes from member names when
putting members into the archive.  For example, if you ask @code{tar} to
add the file @file{/bin/ls} to an archive, it will do so, but the member
name will be @file{bin/ls}.

If you use the @value{absolute-names} option, @code{tar} will do
neither of these transformations.

@format
FIXME: is this what this does, or does it just preserve the slash?  
@end format

To archive or extract files relative to the root directory, specify
the @value{absolute-names} option.

Normally, @code{tar} acts on files relative to the working
directory---ignoring superior directory names when archiving, and
ignoring leading slashes when extracting.

When you specify @value{absolute-names}, @code{tar} stores file names
including all superior directory names, and preserves leading slashes.
If you only invoked @code{tar} from the root directory you would never
need the @value{absolute-names} option, but using this option may be
more convenient than switching to root.

@format
FIXME: should be an example in the tutorial/wizardry section using this
FIXME: to transfer files between systems.
@end format

@format
FIXME: is write access an issue?
@end format

@table @samp
@item --absolute-names
Preserves full file names (inclusing superior dirctory names) when
archiving files.  Preserves leading slash when extracting files.
@end table

@node Being Careful, Format Control, Specifying Names to tar, Top
@chapter Being Even More Careful

@menu
* Documentation::               
* Checking Progress::           
* Interactive Operation::       
* Write Verification::          
* Comparing::                   
* Portability::                 
* Write Protection::            
@end menu

@node Documentation, Checking Progress, Being Careful, Being Careful
@section GNU @code{tar} documentation

Being careful, the first thing is really checking that you are using GNU
@code{tar}, indeed.  The @value{version} option will generate a message
giving confirmation that you are using GNU @code{tar}, with the precise
version of GNU @code{tar} you are using.  @code{tar} identifies itself
and prints the version number to the standard output, then immediately
exits successfully, without doing anything else, ignoring all other
options.  For example, @w{@samp{tar --version}} might return:

@example
GNU tar version @value{VERSION}
@end example

Another thing you might want to do is checking the spelling or meaning
of some particular @code{tar} option, without resorting to this manual,
for once you have carefully read it.  GNU @code{tar} has a short help
feature, triggerable through the @value{help} option.  By using this
option, @code{tar} will print a usage message listing all available
options on standard output, then exit successfully, without doing
anything else and ignoring all other options.  Even if this is only a
brief summary, it may be several screens long.  So, if you are not
using some kind of scrollable window, you might prefer to use something
like:

@example
tar --help | less
@end example

@noindent
presuming, here, that you like using @code{less} for a pager.  Other
popular pagers are @code{more} and @code{pg}.

The perceptive reader would have noticed some contradiction in the
previous paragraphs.  It is written that both @value{version} and
@value{help} print something, and have all other options ignored.  In
fact, they cannot ignore each other, and one of them has to win.  We do
not specify which is stronger, here; experiment if you really wonder!

The short help output is quite succint, and you might have to get back
to the full documentation for precise points.  If you are reading this
paragraph, you already have the @code{tar} manual in some form.  This
manual is available in printed form, as a kind of small book.  It may
printed out of the GNU @code{tar} distribution, provided you have @TeX{}
already installed somewhere, and a laser printer around.  Just configure
the distribution, execute the command @w{@samp{make dvi}}, then print
@file{doc/tar.dvi} the usual way (contact your local guru to know how).
If GNU @code{tar} has been conveniently installed at your place, this
manual is also available in interactive, hypertextual form as an Info
file.  Just call @w{@samp{info tar}} or, if you do not have the
@code{info} program handy, use the Info reader provided within GNU
Emacs, calling @samp{tar} from the main Info menu.

@node Checking Progress, Interactive Operation, Documentation, Being Careful
@section Checking @code{tar} progress

@cindex Progress information
@cindex Status information
@cindex Information on progress and status of operations
@cindex Verbose operation
@cindex Record number where error occured
@cindex Error message, record number of
@cindex Version of the @code{tar} program

@cindex Getting more information during the operation
@cindex Information during operation
@cindex Feedback from @code{tar}

Typically, @code{tar} performs most operations without reporting any
information to the user except error messages.  When using @code{tar}
with many options, particularly ones with complicated or
difficult-to-predict behavior, it is possible to make serious mistakes.
@code{tar} provides several options that make observing @code{tar}
easier.  These options cause @code{tar} to print information as it
progresses in its job, and you might want to use them just for being
more careful about what is going on, or merely for entertaining
yourself.  If you have encountered a problem when operating on an
archive, however, you may need more information than just an error
message in order to solve the problem.  The following options can be
helpful diagnostic tools.

Normally, the @value{list} command to list an archive
prints just the file names (one per line) and the other commands are
silent.  When used with most operations, the @value{verbose} option causes @code{tar} to print the name of each file or
archive member as it is processed.  This and the other options which
make @code{tar} print status information can be useful in monitoring
@code{tar}.

With @value{create} or @value{extract},
@value{verbose} used once just prints the names of the
files or members as they are processed.  Using it twice causes
@code{tar} to print a longer listing (reminiscent of @samp{ls -l}) for
each member.  Since @value{list} already prints the names
of the members, @value{verbose} used once with
@value{list} causes @code{tar} to print an @samp{ls -l}
type listing of the files in the archive.  The following examples both
extract members with long list output:

@example
tar --extract --file=archive.tar --verbose --verbose
tar xvv archive.tar
@end example

Verbose output appears on the standard output except when an archive is
being written to the standard output, as with @samp{tar --create
--file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
installer let standard output be the default archive).  In that case
@code{tar} writes verbose output to the standard error stream.

The @value{totals} option---which is only meaningful when used with
@value{create}---causes @code{tar} to print the total
amount written to the archive, after it has been fully created.

The @value{checkpoint} option prints an occasional message as
@code{tar} reads or writes the archive.  In fact, it print directory
names while reading the archive.  It is designed for those who don't
need the more detailed (and voluminous) output of @value{record-number}, but do want visual confirmation that @code{tar} is actually
making forward progress.
@format
FIXME: There is some confusion here.  It seems that -R once wrote a
FIXME: message at @samp{every} block read or written.
@end format

The @value{show-omitted-dirs} option, when reading an archive---with
@value{list} or @value{extract}, for example---causes a message
to be printed for each directory in the archive which is skipped.
This happens regardless of the reason for skipping: the directory might
not have been named on the command line (implicitly or explicitly),
it might be excluded by the use of the @value{exclude} option, or
some other reason.

If @value{record-number} is used, @code{tar} prints, along
with every message it would normally produce, the record number within
the archive where the message was triggered.  This option is especially
useful when reading damaged archives, since it helps pinpoint the
damaged sections.  It can also be used with @value{list}
when listing a file-system backup tape, allowing you to choose among
several backup tapes when retrieving a file later, in favor of the tape
where the file appears earliest (closest to the front of the tape).
@format
FIXME: xref when the node name is set and the backup section written
@end format

@node Interactive Operation, Write Verification, Checking Progress, Being Careful
@section Asking for Confirmation During Operations
@cindex Interactive operation

Typically, @code{tar} carries out a command without stopping for
further instructions.  In some situations however, you may want to
exclude some files and archive members from the operation (for instance
if disk or storage space is tight).  You can do this by excluding
certain files automatically (
@format
FIXME: pxref File Exclusion
@end format
), or by performing
an operation interactively, using the @value{interactive} option.
@code{tar} also accepts @samp{--confirmation} for this option.

When the @value{interactive} option is specified, before
reading, writing, or deleting files, @code{tar} first prints a message
for each such file, telling what operation it intends to take, then asks
for confirmation on the terminal.  The actions which require
confirmation include adding a file to the archive, extracting a file
from the archive, deleting a file from the archive, and deleting a file
from disk.  To confirm the action, you must type a line of input
beginning with @samp{y}.  If your input line begins with anything other
than @samp{y}, @code{tar} skips that file.

If @code{tar} is reading the archive from the standard input,
@code{tar} opens the file @file{/dev/tty} to support the interactive
communications.
                
@node Write Verification, Comparing, Interactive Operation, Being Careful
@section Verifying Data as It is Stored
@cindex Verifying a write operation
@cindex Double-checking a write operation

You can insure the accuracy of an archive by comparing files in the
system with archive members.  @code{tar} can compare an archive to the
file system as the archive is being written, to verify a write
operation, or can compare a previously written archive, to insure that
it is up to date.

To check for discrepancies in an archive immediately after it is
written, use the @value{verify} option in conjunction with
the @value{create} operation.  When this option is
specified, @code{tar} checks archive members against their counterparts
in the file system, and reports discrepancies on the standard error.  In
multi-volume archives, each volume is verified after it is written,
before the next volume is written.

To verify an archive, you must be able to read it from before the end
of the last written entry.  This option is useful for detecting data
errors on some tapes.  Archives written to pipes, some cartridge tape
drives, and some other devices cannot be verified.

@node Comparing, Portability, Write Verification, Being Careful
@section Comparing an Archive with the File System
@cindex Verifying the currency of an archive
@include docwarn.texi

@value{compare} compares archive members in an existing archive
with their counterparts in the file system, and reports differences in
file size, mode, owner, modification date and contents.  If a file is
represented in the archive but does not exist in the file system,
@code{tar} reports a difference.

If you use @var{file name} arguments in conjunction with @samp{tar
--compare}, @code{tar} compares the archived versions of the files
specified with their counterparts in the file system.  If you specify
a file that is not in the archive, @code{tar} will report an error.  If
you don't specify any files, @code{tar} compares all the files in the
archive.

Because @code{tar} only checks files in the archive against files in
the file system, and not vice versa, it ignores files in the file
system that do not exist in the archive.

The following example compares the archive members @file{larry},
@file{moe} and @file{curly} in the archive @file{stooges} with files
of the same name in the file system.

@example
tar --compare --file=stooges larry moe curly
@end example

@noindent 
If a file, for example @file{curly}, did not exist in the archive,
@code{tar} would report an error, as follows:

@example
curly: does not exist
@end example

@node Portability, Write Protection, Comparing, Being Careful
@section Making @code{tar} Archives More Portable

Creating a @code{tar} archive on a particular system, meant to be later
useful on many other machines and with other versions of @code{tar},
is more a challenge than you might think.  @code{tar} archive formats
evolved since the first versions of Unix, many such formats are flying
around, not always comptabile between them.  This section wants to
discuss a few problems, and give some advice, for making @code{tar}
archives more portable.

One golden rule is simplicity.  For example, limit your @code{tar}
archives to contain only regular files and directories, avoiding
other kind of special files.  Do not attempt to save sparse files or
contiguous files as such.  Let's discuss a few more problems, in turn.

@menu
* Portable Names::              
* Symbolic Links::              
* Old V7 and POSIX::            
* Checksumming Problems::       
@end menu

@node Portable Names, Symbolic Links, Portability, Portability
@subsection Portable Names

Use @emph{straight} file and directory names,
made up of printable ASCII characters, avoiding colons, slashes,
backslashes, and other @emph{dangerous} characters.  Avoid deep
directory nesting.  Accounting for oldish System V machines, limit
your file and directory names to 14 characters or less.

If you intend to have your @code{tar} archives to be read under MSDOS,
you should not rely on case distinction for file names, and you might
use the GNU @code{doschk} program for helping you further diagnosing
illegal MSDOS names, which are even more limited than System V's.

@node Symbolic Links, Old V7 and POSIX, Portable Names, Portability
@subsection Symbolic Links
@cindex File names, using symbolic links
@cindex Symbolic link as file name

Normally, when @code{tar} archives a symbolic link, it writes a
record to the archive naming the target of the link.  In that way, the
@code{tar} archive is a faithful record of the filesystem contents.
@value{dereference} is used with @value{create}, and causes @code{tar} to archive the files symbolic
links point to, instead of the links themselves.  When this option
is used, when @code{tar} encounters a symbolic link, it will archive
the linked-to file, instead of simply recording the presence of a
symbolic link.

The name under which the file is stored in the file system is not
recorded in the archive.  To record both the symbolic link name and
the file name in the system, archive the file under both names.  If
all links were recorded automatically by @code{tar}, an extracted file
might be linked to a file name that no longer exists in the file
system.

If a linked-to file is encountered again by @code{tar} while creating
the same archive, an entire second copy of it will be stored.  (This
@emph{might} be considered a bug.)

So, for portable archives, do not archive symbolic links as such,
and use @value{dereference}: many systems do not support
symbolic links, and moreover, your distribution might be unusable if
it contains unresolved symbolic links.

@node Old V7 and POSIX, Checksumming Problems, Symbolic Links, Portability
@subsection Old V7 and POSIX Archives

GNU @code{tar} implements an early draft of the POSIX 1003.1
@code{ustar} standard which is different from the final standard.
Adding support for the new changes in a backward-compatible fashion
is not trivial.

@cindex Format, old style
@cindex Old style format
@cindex Old style archives

Certain old versions of @code{tar} cannot handle additional
information recorded by newer @code{tar} programs.  To create an
archive in V7 format (not ANSI), which can be read by these old
versions, specify the @value{old-archive} option in
conjunction with the @value{create}.  @code{tar} also
accepts @samp{--portability} for this option.  When you specify it,
@code{tar} leaves out information about directories, pipes, fifos,
contiguous files, and device files, and specifies file ownership by
group and user IDs instead of group and user names.

When updating an archive, do not use @value{old-archive}
unless the archive was created with using this option.

In most cases, a @emph{new} format archive can be read by an @emph{old}
@code{tar} program without serious trouble, so this option should
seldom be needed.  On the other hand, most modern @code{tar}s are
able to read old format archives, so it might be safer for you to
always use @value{old-archive} for your distributions.

@node Checksumming Problems,  , Old V7 and POSIX, Portability
@subsection Checksumming Problems

SunOS and HP-UX @code{tar} fail to accept archives created using GNU
@code{tar} and containing non-ASCII file names, because they use signed
checksums, while GNU @code{tar} uses unsigned checksums while creating
archives, as per POSIX standards.  On reading, GNU @code{tar} computes
both checksums and accept any.  It is somewhat worrying that a lot of
people may go around doing backup of their files using faulty (or at
least non-standard) software, not learning about it until it's time to
restore their missing files with an incompatible file extractor, or vice
versa.

GNU @code{tar} is supposed to compute both checksums, signed and
unsigned, and accept any.  However, 1.11.2 has a bug by which signed
checksums are incorrectly initialized, so they do not work.  This is
corrected in the subsequent GNU @code{tar} versions.  However, GNU
@code{tar} has not been modified to @emph{produce} incorrect archives to
be read by buggy @code{tar}'s.

I've been told that when Sun first imported @code{tar} on their
system, they recompiled it without realizing that the checksums were
computed differently, because of a change in the default signing of
@code{char}'s in their compiler.  So they started computing checksums
wrongly, and stayed compatible with themselves afterwards.  It now
falls on the shoulders of SunOS and HP-UX users to get a @code{tar}
able to read the good archives they receive.

@node Write Protection,  , Portability, Being Careful
@section Write Protection

All tapes and disks can be @dfn{write protected}, to protect data on
them from being changed.  Once an archive is written, you should write
protect the media to prevent the archive from being accidently
overwritten or deleted.  (This will protect the archive from being
changed with a tape or floppy drive---it will not protect it from
magnet fields or other physical hazards).

The write protection device itself is usually an integral part of the
physical media, and can be a two position (write enabled/write
disabled) switch, a notch which can be popped out or covered, a ring
which can be removed from the center of a tape reel, or some other
changeable feature.

@node Format Control, Media, Being Careful, Top
@chapter Controlling the Archive Format

@menu
* Attributes Options::          
* Type Options::                
* Compression::                 
* Special Options for Archiving::  
* Archive Structure::           
* Modifiers Options::           
@end menu

@node Attributes Options, Type Options, Format Control, Format Control
@section Handling of file attributes
@include docwarn.texi

Handling of file attributes

@table @code

@item --atime-preserve
Do not change access times on dumped files.

@item -m
@itemx --modification-time
Do not extract file modified time.

When this option is used, @code{tar} leaves the modification times
of the files it extracts as the time when the files were extracted,
instead of setting it to the time recorded in the archive.

This option is meaningless with @value{list}.

@item --same-owner
Create extracted files with the same ownership.

@item -p
@itemx --same-permissions
@itemx --preserve-permissions
Extract all protection information.

This option causes @code{tar} to set the modes (access permissions) of
extracted files exactly as recorded in the archive.  If this option
is not used, the current @code{umask} setting limits the permissions
on extracted files.

This option is meaningless with @value{list}.

@item -s
@itemx --same-order
@itemx --preserve-order
Sort names to extract to match archive.

This option tells @code{tar} that the list of file names to be listed
or extracted is sorted in the same order as the files in the archive.
This allows a large list of names to be used, even on a small machine
that would not otherwise be able to hold all the names in memory at
the same time.  Such a sorted list can easily be created by running
@samp{tar -t} on the archive and editing its output.

This option is probably never needed on modern computer systems.

@item --preserve
Same as both @value{same-permissions} and @value{same-order}.

The @value{preserve} option has no equivalent short option name.
It is equivalent to @value{same-permissions} plus @value{same-order}.

@end table

@node Type Options, Compression, Attributes Options, Format Control
@section Archive format selection
@include docwarn.texi

Archive format selection

@table @code

@item -V @var{name}
@itemx --label=@var{name}
Create archive with volume name @var{name}.

This option causes @code{tar} to write out a @dfn{volume header} at
the beginning of the archive.  If @value{multi-volume} is used, each
volume of the archive will have a volume header of @samp{@var{name}
Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
next, and so on.

@item -z
@itemx --gzip
@itemx --ungzip
Filter the archive through @code{gzip}.

This option works on physical devices (tape drives, etc.) and remote
files as well as on normal files; data to or from such devices or
remote files is reblocked by another copy of the @code{tar} program
to enforce the specified (or default) block size.  The default
compression parameters are used; if you need to override them, avoid
the @value{gzip} option and run @code{gzip} explicitly.  (Or set the
@samp{GZIP} environment variable.)

If the @value{gzip} option is given twice, or the
@value{compress-block} option is used, @code{tar} will pad the archive
out to the next block boundary (
@format
FIXME: pxref Blocking
@end format
).  This may be useful
with some devices that require that all write operations be a multiple
of a certain size.

The @value{gzip} option does not work with the @value{multi-volume}
option, or with the @value{update}, @value{append},
@value{concatenate}, or @value{delete} commands.

It is not exact to say that GNU @code{tar} is to work in concert
with @code{gzip} in a way similar to @code{zip}, say.  Surely, it is
possible that @code{tar} and @code{gzip} be done with a single call,
like in:

@example
tar cfz archive.tar.gz subdir
@end example

@noindent
to save all of @samp{subdir} into a @code{gzip}'ed archive.  Later you
can do:

@example
tar xfz archive.tar.gz
@end example

@noindent
to explode and unpack.

The difference is that the whole archive is compressed.  With
@code{zip}, archive members are archived individually.  @code{tar}'s
method yields better compression.  On the other hand, one can view the
contents of a @code{zip} archive without having to decompress it.  As
for the @code{tar} and @code{gzip} tandem, you need to decompress the
archive to see its contents.  However, this may be done without needing
disk space, by using pipes internally:

@example
tar tfz archive.tar.gz
@end example

@cindex corrupted archives
About corrupted compressed archives: @code{gzip}'ed files have no
redundancy, for maximum compression.  The adaptive nature of the
compression scheme means that the compression tables are implicitly
spread all over the archive.  If you lose a few blocks, the dynamic
construction of the compression tables becomes unsychronized, and there
is little chance that you could recover later in the archive.

There are pending suggestions for having a per-volume or per-file
compression in GNU @code{tar}.  This would allow for viewing the
contents without decompression, and for resynchronizing decompression at
every volume or file, in case of corrupted archives.  Doing so, we might
loose some compressibility.  But this would have make recovering easier.
So, there are pros and cons.  We'll see!

@item -Z
@itemx --compress
@itemx --uncompress
Filter the archive through @code{compress}.  Otherwise like @value{gzip}.

@item --use-compress-program=@var{prog}
Filter through @var{prog} (must accept @samp{-d}).

@end table

@node Compression, Special Options for Archiving, Type Options, Format Control
@section Using Less Space through Compression

@menu
* Compressed Archives::         
* Dealing with Compressed Archives::  
* Sparse Files::                
@end menu

@node Compressed Archives, Dealing with Compressed Archives, Compression, Compression
@subsection Creating and Reading Compressed Archives
@cindex Compressed archives
@cindex Storing archives in compressed format
@include docwarn.texi

@value{compress} indicates an archive stored in compressed format.
The @value{compress} option is useful in saving time over networks and
space in pipes, and when storage space is at a premium.
@value{compress} causes @code{tar} to compress when writing the
archive, or to uncompress when reading the archive.

To perform compression and uncompression on the archive, @code{tar}
runs the @code{compress} utility.  @code{tar} uses the default
compression parameters; if you need to override them, avoid the
@value{compress} option and run the @code{compress} utility
explicitly.  It is useful to be able to call the @code{compress}
utility from within @code{tar} because the @code{compress} utility by
itself cannot access remote tape drives.

The @value{compress} option will not work in conjunction with the
@value{multi-volume} option or the @value{append}, @value{update},
@value{append} and @value{delete} operations.
@format
FIXME: xref Modifying
@end format
, for
more information on these operations.

If there is no compress utility available, @code{tar} will report an
error.

@value{compress-block} is like @value{compress}, but when used in
conjunction with @value{create} also causes @code{tar} to pad the last
block of the archive out to the next block boundary as it is written.
This is useful with certain devices which require all write operations
be a multiple of a specific size.

@quotation
@strong{Please Note:} The @code{compress} program may be covered by a patent,
and therefore we recommend you stop using it.  We hope to have a
different compress program in the future.  We may change the name of
this option at that time.
@end quotation

@table @samp
@item --compress
@itemx --uncompress
@itemx -z
@itemx -Z
When this option is specified, @code{tar} will compress (when writing
an archive), or uncompress (when reading an archive).  Used in
conjunction with the @value{create}, @value{extract}, @value{list} and
@value{compare} operations.

@item --compress-block
@itemx -z -z
Acts like @value{compress}, but pads the archive out to the next block
boundary as it is written when used in conjunction with the
@value{create} operation.
@end table

@format
FIXME: why not use -Z instead of -z -z ?
@end format

@node Dealing with Compressed Archives, Sparse Files, Compressed Archives, Compression
@subsection Dealing with Compressed Archives
@include docwarn.texi

You can have archives be compressed by using the @value{gzip} option.
This will arrange for @code{tar} to use the @code{gzip} program to be
used to compress or uncompress the archive wren writing or reading it.

To use the older, obsolete, @code{compress} program, use the
@value{compress} option.  The GNU Project recommends you not use
@code{compress}, because there is a patent covering the algorithm
it uses.  Merely by running @code{compress} you could be sued for
patent infringment.

When using either @value{gzip} or @value{compress}, @code{tar} does
not do blocking (
@format
FIXME: pxref Blocking
@end format
) correctly.  Use @samp{--gzip-block}
or @value{compress-block} instead when using real tape drives.

@node Sparse Files,  , Dealing with Compressed Archives, Compression
@subsection Archiving Sparse Files
@cindex Sparse Files
@include docwarn.texi

A file is sparse if it contains blocks of zeros whose existance is
recorded, but that have no space allocated on disk.  When you specify
the @value{sparse} option in conjunction with the @value{create}
operation, @code{tar} tests all files for sparseness while archiving.
If @code{tar} finds a file to be sparse, it uses a sparse
representation of the file in the archive.
@format
FIXME: xref Creating Archives
@end format
,
for more information about creating archives.

@value{sparse} is useful when archiving files, such as dbm files,
likely to contain many nulls.  This option dramatically
decreases the amount of space needed to store such an archive.  

@quotation
@strong{Please Note:} Always use @value{sparse} when performing file
system backups, to avoid archiving the expanded forms of files stored
sparsely in the system.@refill

Even if your system has no no sparse files currently, some may be
created in the future.  If you use @value{sparse} while making file
system backups as a matter of course, you can be assured the archive
will always take no more space on the media than the files take on
disk (otherwise, archiving a disk filled with sparse files might take
hundreds of tapes).@refill
@format
FIXME: xref incremental when node name is set.
@end format
@end quotation

@code{tar} ignores the @value{sparse} option when reading an archive.

@table @samp
@item --sparse
@itemx -S
Files stored sparsely in the file system are represented sparsely in
the archive.  Use in conjunction with write operations.
@end table  

@node Special Options for Archiving, Archive Structure, Compression, Format Control
@section Special Options for Archiving
@include docwarn.texi

To give the archive a name which will be recorded in it, use the
@value{label} option.  This will write a special record identifying
@var{volume-label} as the name of the archive to the front of
the archive which will be displayed when the archive is listed
with @value{list}.  If you are creating a multi-volume archive with
@value{multi-volume} (
@format
FIXME: pxref Using Multiple Tapes
@end format
), then the volume
label will have @samp{Volume @var{nnn}} appended to the name you
give, where @var{nnn} is the number of the volume of the archive.
(If you use the @value{label} option when reading an archive, it
checks to make sure the label on the tape matches the one you give.

@format
FIXME: xref Special Options for Archiving
@end format
.)

Files in the filesystem occasionally have ``holes.''  A hole in a file
is a section of the file's contents which was never written.  The
contents of a hole read as all zeros.  On many operating systems, actual@c 
disk storage is not allocated for holes, but they are counted in the
length of the file.  If you archive such a file, @code{tar} could create
an archive longer than the original.  To have @code{tar} attempt to
recognize the holes in a file, use @value{sparse}.  When you use the 
@value{sparse} option, then, for any file using less disk space than
would be expected from its length, @code{tar} searches the file for
consecutive stretches of zeros.  It then records in the archive for the
file where the consecutive stretches of zeros are, and only archives the
``real contents'' of the file.  On extraction (using @value{sparse} is
not needed on extraction) any such files have hols created wherever the
continuous stretches of zeros were found.  Thus, if you use
@value{sparse}, @code{tar} archives won't take more space than the
original.

When @code{tar} reads files, this causes them to have the access times
updated.  To have @code{tar} attempt to set the access times back to
what they were before they were read, use the @value{atime-preserve}
option.  This doesn't work for files that you don't own, unless you're
root, and it doesn't interact with incremental dumps nicely
(
@format
FIXME: pxref Making Backups
@end format
), but it is good enough for some purposes.

@node Archive Structure, Modifiers Options, Special Options for Archiving, Format Control
@section The Structure of an Archive
@include docwarn.texi

While an archive may contain many files, the archive itself is a
single ordinary file.  Like any other file, an archive file can be
written to a storage device such as a tape or disk, sent through a
pipe or over a network, saved on the active file system, or even
stored in another archive.  An archive file is not easy to read or
manipulate without using the @code{tar} utility or Tar mode in Emacs.


Physically, an archive consists of a series of file entries terminated
by an end-of-archive entry, which consists of 512 zero bytes.  A file
entry usually describes one of the files in the archive (an
@dfn{archive member}), and consists of a file header and the contents
of the file.  File headers contain file names and statistics, checksum
information which @code{tar} uses to detect file corruption, and
information about file types. 

More than archive member can have the same file name.  One way this
situation can occur is if more than one version of a file has been
stored in the archive.  For information about adding new versions of a
file to an archive,
@format
FIXME: pxref Modifying
@end format
.

In addition to entries describing archive members, an archive may contain
entries which @code{tar} itself uses to store information.

@format
FIXME: xref Archive Label
@end format
, for an example of such an archive entry.

@node Modifiers Options,  , Archive Structure, Format Control
@section Operation mode modifiers
@include docwarn.texi

Operation mode modifiers

@table @code

@item -W
@itemx --verify
Attempt to verify the archive after writing.

This option causes @code{tar} to verify the archive after writing it.
Each volume is checked after it is written, and any discrepancies
are recorded on the standard error output.

Verification requires that the archive be on a back-space-able medium.
This means pipes, some cartridge tape drives, and some other devices
cannot be verified.

@item --remove-files
Remove files after adding them to the archive.

@item -k
@itemx --keep-old-files
Do not overwrite existing files from archive.

The @value{keep-old-files} option prevents @code{tar} from over-writing
existing files with files with the same name from the archive.

The @value{keep-old-files} option is meaningless with @value{list}.

@item -S
@itemx --sparse
Handle sparse files efficiently.

This option causes all files to be put in the archive to be tested for
sparseness, and handled specially if they are.  The @value{sparse}
option is useful when many @code{dbm} files, for example, are being
backed up.  Using this option dramatically decreases the amount of
space needed to store such a file.

In later versions, this option may be removed, and the testing and
treatment of sparse files may be done automatically with any special
GNU options.  For now, it is an option needing to be specified on
the command line with the creation or updating of an archive.

@item -O
@itemx --to-stdout
Extract files to standard output.

When this option is used, instead of creating the files specified,
@code{tar} writes the contents of the files extracted to its standard
output.  This may be useful if you are only extracting the files in
order to send them through a pipe.

This option is meaningless with @value{list}.

@item --ignore-failed-read
Do not exit with non-zero on unreadable files.

@end table

@format
FIXME: This section needs to be written
@end format

@strong{To come:} using Unix file linking capability to recreate directory
structures---linking files into one subdirectory and then @code{tar}ring that
directory.   

@strong{to come:} nice hairy example using absolute-names, newer, etc.

Piping one @code{tar} to another is an easy way to copy a directory's
contents from one disk to another, while preserving the dates, modes, owners
and link-structure of all the files therein.

@example
cd sourcedirectory; tar cf - . | (cd targetdir; tar xf -)
@end example

@noindent
or

@format
FIXME: the following using standard input/output correct??
@end format
@example
cd sourcedirectory; tar --create --file=- . | (cd targetdir; tar --extract --file=-)
@end example

@noindent

Archive files can be used for transporting a group of files from one system
to another:  put all relevant files into an archive on one computer system,
transfer the archive to another, and extract the contents there. The basic
transfer medium might be magnetic tape, Internet FTP, or even electronic
mail (though you must encode the archive with @code{uuencode} in order to
transport it properly by mail).  Both machines do not have to use the same
operating system, as long as they both support the @code{tar} program.
@findex uuencode
@format
FIXME: mention uuencode on a paragraph of its own
@end format

@format
FIXME: end construction
@end format

@node Media, Backups and Restoration, Format Control, Top
@chapter Tapes and Other Archive Media
@include docwarn.texi

A few special cases about tape handling warrant more detailed
description.  These special cases are discussed below.

Many complexities surround the use of @code{tar} on tape drives.  Since
the creation and manipulation of archives located on magnetic tape was
the original purpose of @code{tar}, it contains many features making
such manipulation easier.

Archives are usually written on dismountable media---tape cartridges,
mag tapes, or floppy disks.

The amount of data a tape or disk holds depends not only on its size,
but also on how it is formatted.  A 2400 foot long reel of mag tape
holds 40 megabytes of data when formated at 1600 bits per inch.  The
physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.  

Magnetic media are re-usable---once the archive on a tape is no longer
needed, the archive can be erased and the tape or disk used over.
Media quality does deteriorate with use, however.  Most tapes or disks
should be disgarded when they begin to produce data errors.  EXABYTE
tape cartridges should be disgarded when they generate an @dfn{error
count} (number of non-usable bits) of more than 10k.

Magnetic media are written and erased using magnetic fields, and
should be protected from such fields to avoid damage to stored data.
Sticking a floppy disk to a filing cabinet using a magnet is probably
not a good idea.

@menu
* Device::                      
* Blocking::                    
* Many::                        
* Using Multiple Tapes::        
* Archive Label::               
@end menu

@node Device, Blocking, Media, Media
@section Device selection and switching
@include docwarn.texi

@table @code

@item -f [@var{hostname}:]@var{file}
@itemx --file=[@var{hostname}:]@var{file}
Use archive file or device @var{file} on @var{hostname}.

This option is used to specify the file name of the archive @code{tar}
works on.

If the file name is @samp{-}, @code{tar} reads the archive from standard
input (when listing or extracting), or writes it to standard output
(when creating).  If the @samp{-} file name is given when updating an
archive, @code{tar} will read the original archive from its standard
input, and will write the entire new archive to its standard output.

If the file name contains a @samp{:}, it is interpreted as
@samp{hostname:filename}.  If the @var{hostname} contains an @dfn{at}
sign (@kbd{@@}), it is treated as @samp{user@@hostname:filename}.  In
either case, @code{tar} will invoke the command @code{rsh} (or
@code{remsh}) to start up an @file{/etc/rmt} on the remote machine.  If
you give an alternate login name, it will be given to the @code{rsh}.
Naturally, the remote machine must have an executable @file{/etc/rmt}.
This program is free software from the University of California, and a
copy of the source code can be found with the sources for @code{tar};
it's compiled and installed by default.

If this option is not given, but the environment variable @code{TAPE} is
set, its value is used; otherwise, old versions of @code{tar} used a default
archive name (which was picked when @code{tar} was compiled).  The
default is normally set up to be the @dfn{first} tape drive or other
transportable I/O medium on the system.

Starting with version 1.11.5, GNU @code{tar} uses standard input and
standard output as the default device, and I will not try anymore
supporting automatic device detection at installation time.  This was
failing really in too many cases, it was hopeless.  This is now
completely left to the installer to override standard input and standard
output for default device, if this seems preferrable to him/her.
Further, I think @emph{most} actual usages of @code{tar} are done with
pipes or disks, not really tapes, cartridges or diskettes.

Some users think that using standard input and output is running
after trouble.  This could lead to a nasty surprise on your screen if
you forget to specify an output file name---especially if you are going
through a network or terminal server capable of buffering large amounts
of output.  We had so many bug reports in that area of configuring
default tapes automatically, and so many contradicting requests, that
we finally consider the problem to be portably intractable.  We could
of course use something like @samp{/dev/tape} as a default, but this
is @emph{also} running after various kind of trouble, going from hung
processes to accidental destruction of real tapes.  After having seen
all this mess, using standard input and output as a default really
sounds like the only clean choice left, and a very useful one too.

GNU @code{tar} reads and writes archive in blocks, I suspect this is the
main reason why block devices are preferred over character devices.
Most probably, block devices are more efficient too.  The installer
could also check for @samp{DEFTAPE} in @file{<sys/mtio.h>}.

@item --force-local
Archive file is local even if it contains a colon.

@item --rsh-command=@var{command}
Use remote @var{command} instead of @code{rsh}.  This option exists
so that people who use something other than the standard @code{rsh}
(e.g., a Kerberized @code{rsh}) can access a remote device.

When this command is not used, the shell command found when
the @code{tar} program was installed is used instead.  This is
the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
@file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
The installer may have overriden this by defining the environment
variable @code{RSH} @emph{at installation time}.

@item -[0-7][lmh]
Specify drive and density.

@item -M
@itemx --multi-volume
Create/list/extract multi-volume archive.

This option causes @code{tar} to write a @dfn{multi-volume}
archive---one that may be larger than will fit on the medium used to
hold it.
@format
FIXME: xref Multi
@end format
.

@item -L @var{num}
@itemx --tape-length=@var{num}
Change tape after writing @var{num} x 1024 bytes.

This option might be useful when your tape drivers do not properly
detect end of physical tapes.  By being slightly conservative on the
maximum tape length, you might avoid the problem entirely.

@item -F @var{file}
@itemx --info-script=@var{file}
@itemx --new-volume-script=@var{file}
Execute @file{file} at end of each tape.  This implies
@value{multi-volume}.

@end table

The Remote Tape Server

@cindex remote tape drive
@pindex rmt

In order to access the tape drive on a remote machine, @code{tar}
uses the remote tape server written at the University of California at
Berkeley.  The remote tape server must be installed as @file{/etc/rmt}
on any machine whose tape drive you want to use.  @code{tar} calls
@file{/etc/rmt} by running an @code{rsh} or @code{remsh} to the remote
machine, optionally using a different login name if one is supplied.

A copy of the source for the remote tape server is provided.  It is
Copyright @copyright{} 1983 by the Regents of the University of
California, but can be freely distributed.  Instructions for compiling
and installing it are included in the @file{Makefile}.

@cindex absolute file names
Unless you use the @value{absolue-names} option, GNU @code{tar} will
not allow you to create an archive that contains absolute file names
(a file name beginning with @samp{/}.) If you try, @code{tar} will
automatically remove the leading @samp{/} from the file names it
stores in the archive.  It will also type a warning message telling
you what it is doing.

When reading an archive that was created with a different @code{tar}
program, GNU @code{tar} automatically extracts entries in the archive
which have absolute file names as if the file names were not absolute.
This is an important feature.  A visitor here once gave a
@code{tar} tape to an operator to restore; the operator used Sun @code{tar}
instead of GNU @code{tar}, and the result was that it replaced large
portions of our @file{/bin} and friends with versions from the tape;
needless to say, we were unhappy about having to recover the file system
from backup tapes.

For example, if the archive contained a file @file{/usr/bin/computoy},
GNU @code{tar} would extract the file to @file{usr/bin/computoy},
relative to the current directory.  If you want to extract the files in
an archive to the same absolute names that they had when the archive
was created, you should do a @samp{cd /} before extracting the files
from the archive, or you should either use the @value{absolute-names}
option, or use the command @samp{tar -C / @dots{}}.

@cindex Ultrix 3.1 and write failure
Some versions of Unix (Ultrix 3.1 is know to have this problem),
can claim that a short write near the end of a tape succeeded,
when it actually failed.  This will result in the -M option not
working correctly.  The best workaround at the moment is to use a
significantly larger blocksize than the default 20.

In order to update an archive, @code{tar} must be able to backspace the
archive in order to reread or rewrite a block that was just read (or
written).  This is currently possible only on two kinds of files: normal
disk files (or any other file that can be backspaced with @samp{lseek}),
and industry-standard 9-track magnetic tape (or any other kind of tape
that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.

This means that the @value{append}, @value{update},
@value{concatenate}, and @value{delete} commands will not work on any
other kind of file.  Some media simply cannot be backspaced, which
means these commands and options will never be able to work on them.
These non-backspacing media include pipes and cartridge tape drives.

Some other media can be backspaced, and @code{tar} will work on them
once @code{tar} is modified to do so.

Archives created with the @value{multi-volume}, @value{label}, and
@value{incremental} options may not be readable by other version
of @code{tar}.  In particular, restoring a file that was split over
a volume boundary will require some careful work with @code{dd}, if
it can be done at all.  Other versions of @code{tar} may also create
an empty file whose name is that of the volume header.  Some versions
of @code{tar} may create normal files instead of directories archived
with the @value{incremental} option.

Some Common Problems and their Solutions:

@format
errors from system:
permission denied
no such file or directory
not owner

errors from @code{tar}:
directory checksum error
header format error

errors from media/system:
i/o error
device busy
@end format

@node Blocking, Many, Device, Media
@section Blocking
@include docwarn.texi

When writing to tapes, @code{tar} writes the contents of the archive
in chunks known as @dfn{blocks}.  To change the default blocksize,
use the @value{block-size} option.  Each block will then be composed
of @var{size} records.  (Each @code{tar} record is 512 bytes.

@format
FIXME: xref Archive Format
@end format
.)  Each file written to the archive uses at
least one full block.  As a result, using a larger block size can
result in more wasted space for small files.  On the other hand, a
larger block size can ofter be read and written much more efficiently.

Further complicating the problem is that some tape drives ignore the
blocking entirely.  For these, a larger block size can still improve
performance (because the software layers above the tape drive still
honor the blocking), but not as dramatically as on tape drives that
honor blocking.

Wher reading an archive, @code{tar} can usually figure out the block
size on itself.  When this is the case, and a non-standard block size
was used when the archive was created, @code{tar} will print a message
about a non-standard blocking factor, and then operate normally.  On
some tape devices, however, @code{tar} cannot figure out the block size
itself.  On most of those, you can specify a blocking factor (with
@value{block-size}) larger than the actual blocking factor, and then use
the @value{read-full-blocks} option.  (If you specify a blocking factor
with @value{block-size} and don't use the @value{read-full-blocks}
option, then @code{tar} will not attempt to figure out the blocking size
itself.)  On some devices, you must always specify the block size
exactly with @value{block-size} when reading, because @code{tar} cannot
figure it out.  In any case, use @value{list} before doing any
extractions to see whether @code{tar} is reading the archive correctly.

If you use a blocking factor larger than 20, older @code{tar} programs
might not be able to read the archive, so we recommend this as a limit
to use in practice.  GNU @code{tar}, however, will support arbitrarily
large block sizes, limited only by the amount of virtual memory or the
physical characteristics of the tape device.

If you are writing a compressed archive to tape with @value{compress}
or @value{gzip} (
@format
FIXME: pxref Input and Output
@end format
), @code{tar} will not block
the archive correctly.  This doesn't matter if you are writing the
archive to a normal file or through a pipe, but if you are writing it to
a tape drive, then this causes problems.  Use @value{compress-block} or
@samp{--gzip-block} instead, to cause @code{tar} to arrange to have
blocking work correctly.

@menu
* Format Variations::           
* Blocking Factor::             
@end menu

@node Format Variations, Blocking Factor, Blocking, Blocking
@subsection Format Variations
@cindex Format Parameters
@cindex Format Options
@cindex Options to specify archive format.
@include docwarn.texi

Format parameters specify how an archive is written on the archive
media.  The best choice of format parameters will vary depending on
the type and number of files being archived, and on the media used to
store the archive.

To specify format parameters when accessing or creating an archive,
you can use the options described in the following sections.  If you
do not specify any format parameters, @code{tar} uses default
parameters.  You cannot modify a compressed archive.  If you create an
archive with the @value{block-size} option specified (
@format
FIXME: pxref Blocking
Factor
@end format
), you must specify that block-size when operating on the
archive.
@format
FIXME: xref Matching Format Parameters
@end format
, for other examples of
format parameter considerations.

@node Blocking Factor,  , Format Variations, Blocking
@subsection The Blocking Factor of an Archive
@cindex Blocking Factor
@cindex Block Size
@cindex Number of records per block
@cindex Number of bytes per block
@cindex Bytes per block
@cindex Records per block
@include docwarn.texi

The data in an archive is grouped into records, which are 512 bytes.
Records are read and written in whole number multiples called
@dfn{blocks}.  The number of records in a block (ie. the size of a
block in units of 512 bytes) is called the @dfn{blocking factor}.
The @value{block-size} option specifies the blocking factor of
an archive.  The default blocking factor is typically 20 (ie.@:
10240 bytes), but can be specified at installation.  To find out
the blocking factor of an existing archive, use @samp{tar --list
--file=@var{archive-name}}.  This may not work on some devices.

Blocks are seperated by gaps, which waste space on the archive media. 
If you are archiving on magnetic tape, using a larger blocking factor
(and therefore larger blocks) provides faster throughput and allows
you to fit more data on a tape (because there are fewer gaps). If you
are archiving on cartridge, a very large blocking factor (say 126 or
more) greatly increases performance. A
smaller blocking factor, on the other hand, may be usefull when
archiving small files, to avoid archiving lots of nulls as @code{tar}
fills out the archive to the end of the block. In general, the ideal block size
depends on the size of the inter-block gaps on the tape you are using,
and the average size of the files you are archiving.
@format
FIXME: xref Creating
Archives
@end format
, for information on writing archives.
@format
FIXME: need example of using a cartridge with blocksize=126 or more
@end format

Archives with blocking factors larger than 20 cannot be read by very
old versions of @code{tar}, or by some newer versions of @code{tar}
running on old machines with small address spaces.  With GNU
@code{tar}, the blocking factor of an archive is limited only by the
maximum block size of the device containing the archive, or by the
amount of available virtual memory.

If you use a non-default blocking factor when you create an archive,
you must specify the same blocking factor when you modify that
archive.  Some archive devices will also require you to specify the
blocking factor when reading that archive, however this is not
typically the case.  Usually, you can use @value{list} without
specifying a blocking factor---@code{tar} reports a non-default block
size and then lists the archive members as it would normally.  To
extract files from an archive with a non-standard blocking factor
(particularly if you're not sure what the blocking factor is), you can
usually use the @value{read-full-blocks} option while specifying a blocking
factor larger then the blocking factor of the archive (ie. @samp{tar
--extract --read-full-blocks --block-size=300}.
@format
FIXME: xref Listing Contents
@end format

for more information on the @value{list} operation.

@format
FIXME: xref read-full-blocks
@end format
for a more detailed explanation of that
option.

@table @samp
@item --block-size=@var{number}
@itemx -b @var{number}
Specifies the blocking factor of an archive.  Can be used with any
operation, but is usually not necessary with @value{list}.
@end table

Device blocking

@table @code

@item -b @var{blocks}
@itemx --block-size=@var{blocks}
Set block size to @math{@var{blocks} * 512} bytes.

This option is used to specify a @dfn{blocking factor} for the archive.
When reading or writing the archive, @code{tar}, will do reads and
writes of the archive in blocks of @math{@var{block}*512} bytes.

The default blocking factor is set when @code{tar} is compiled, and
is typically 20.

Blocking factors larger than 20 cannot be read by very old versions
of @code{tar}, or by some newer versions of @code{tar} running on
old machines with small address spaces.

With a magnetic tape, larger blocks give faster throughput and fit
more data on a tape (because there are fewer inter-record gaps).
If the archive is in a disk file or a pipe, you may want to specify
a smaller blocking factor, since a large one will result in a large
number of null bytes at the end of the archive.

When writing cartridge or other streaming tapes, a much larger
blocking factor (say 126 or more) will greatly increase performance.
However, you must specify the same blocking factor when reading or
updating the archive.

With GNU @code{tar} the blocking factor is limited only by the maximum
block size of the device containing the archive, or by the amount of
available virtual memory.

@item --block-compress
Block the output of compression for tapes.

@item -i
@itemx --ignore-zeros
Ignore blocks of zeros in archive (means EOF).

The @value{ignore-zeros} option causes @code{tar} to ignore blocks
of zeros in the archive.  Normally a block of zeros indicates the
end of the archive, but when reading a damaged archive, or one which
was created by @code{cat}-ing several archives together, this option
allows @code{tar} to read the entire archive.  This option is not on
by default because many versions of @code{tar} write garbage after
the zeroed blocks.

Note that this option causes @code{tar} to read to the end of the
archive file, which may sometimes avoid problems when multiple files
are stored on a single physical tape.

@item -B
@itemx --read-full-blocks
Reblock as we read (for reading 4.2BSD pipes).

If @value{read-full-blocks} is used, @code{tar} will not panic if an
attempt to read a block from the archive does not return a full block.
Instead, @code{tar} will keep reading until it has obtained a full
block.

This option is turned on by default when @code{tar} is reading
an archive from standard input, or from a remote machine.  This is
because on BSD Unix systems, a read of a pipe will return however
much happens to be in the pipe, even if it is less than @code{tar}
requested.  If this option was not used, @code{tar} would fail as
soon as it read an incomplete block from the pipe.

This option is also useful with the commands for updating an archive.

@end table

Tape blocking

@format
FIXME: Appropriate options should be moved here from elsewhere.
@end format

@cindex blocking factor
@cindex tape blocking

When handling various tapes or cartridges, you have to take care of
selecting a proper blocking, that is, the number of disk blocks you
put together as a single tape block on the tape, without intervening
tape gaps.  A @dfn{tape gap} is a small landing area on the tape
with no information on it, used for decelerating the tape to a
full stop, and for later regaining the reading or writing speed.
When the driver starts reading a tape block, the tape block has to
be read whole without stopping, as a tape gap is needed to stop the
tape motion without loosing information.

@cindex Exabyte blocking
@cindex DAT blocking
Using higher blocking (putting more disk blocks per tape block) will use
the tape more efficiently as there will be less tape gaps.  But reading
such tapes may be more difficult for the system, as more memory will be
required to receive at once the whole block.  Further, if there is a
reading error on a huge tape block, this is less likely that the system
will succeed in recovering the information.  So, blocking should not be
too low, nor it should be too high.  @code{tar} uses by default a
blocking of 20 for historical reasons, and it does not really matter
when reading or writing to disk.  Current tape technology would easily
accomodate higher blockings.  Sun recommends a blocking of 126 for
Exabytes and 96 for DATs.  Other manufacturers may use different
recommendations for the same tapes.  This might also depends of the
buffering techniques used inside modern tape controllers.  Some imposes
a minimum blocking, or a maximum blocking.  Others request blocking to
be some exponent of two.

So, there is no fixed rule for blocking.  But blocking at read time
should ideally be the same as blocking used at write time.  At one place
I know, with a wide variety of equipment, they found it best to use a
blocking of 32 to guarantee that their tapes are fully interchangeable.

I was also told that, for recycled tapes, prior erasure (by the same
drive unit that will be used to create the archives) sometimes lowers
the error rates observed at rewriting time.

@node Many, Using Multiple Tapes, Blocking, Media
@section Many archives on one tape

@format
FIXME: Appropriate options should be moved here from elsewhere.
@end format

@findex ntape @r{device}
Most tape devices have two entries in the @file{/dev} directory, or
entries that come in pairs, which differ only in the minor number for
this device.  Let's take for example @file{/dev/tape}, which often
points to the only or usual tape device of a given system.  There might
be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}.  The simpler
name is the @emph{rewinding} version of the device, while the name
having @samp{nr} in it is the @emph{no rewinding} version of the same
device.

A rewinding tape device will bring back the tape to its beginning point
automatically when this device is opened or closed.  Since @code{tar}
opens the archive file before using it and closes it afterwards, this
means that a simple:

@example
tar cf /dev/tape @var{directory}
@end example

@noindent
will reposition the tape to its beginning both prior and after saving
@var{directory} contents to it, thus erasing prior tape contents and
making it so that any subsequent write operation will destroy what has
just been saved.

@cindex tape positioning
So, a rewinding device is normally meant to hold one and only one file.
If you want to put more than one @code{tar} archive on a given tape, you
will need to avoid using the rewinding version of the tape device.  You
will also have to pay special attention to tape positioning.  Errors in
positionning may overwrite the valuable data already on your tape.  Many
people, burnt by past experiences, will only use rewinding devices and
limit themselves to one file per tape, precisely to avoid the risk of
such errors.  Be fully aware that writing at the wrong position on a
tape loses all information past this point and most probably until the
end of the tape, and this destroyed information @emph{cannot} be
recovered.

To save @var{directory-1} as a first archive at the beginning of a
tape, and leave that tape ready for a second archive, you should use:

@example
mt -f /dev/nrtape rewind
tar cf /dev/nrtape @var{directory-1}
@end example

@cindex tape marks
@dfn{Tape marks} are special magnetic patterns written on the tape
media, which are later recognizable by the reading hardware.  These
marks are used after each file, when there are many on a single tape.
An empty file (that is to say, two tape marks in a row) signal the
logical end of the tape, after which no file exist.  Usually,
non-rewinding tape device drivers will react to the close request issued
by @code{tar} by first writing two tape marks after your archive, and by
backspacing over one of these.  So, if you remove the tape at that time
from the tape drive, it is properly terminated.  But if you write
another file at the current position, the second tape mark will be
erased by the new information, leaving only one tape mark between files.

So, you may now save @var{directory-2} as a second archive after the
first on the same tape by issuing the command:

@example
tar cf /dev/nrtape @var{directory-2}
@end example

@noindent
and so on for all the archives you want to put on the same tape.

Another usual case is that you do not write all the archives the same
day, and you need to remove and store the tape between two archive
sessions.  In general, you must remember how many files are already
saved on your tape.  Suppose your tape already has 16 files on it, and
that you are ready to write the 17th.  You have to take care of skipping
the first 16 tape marks before saving @var{directory-17}, say, by using
these commands:

@example
mt -f /dev/nrtape rewind
mt -f /dev/nrtape fsf 16
tar cf /dev/nrtape @var{directory-17}
@end example

In all the previous examples, we put aside blocking considerations,
but you should do the proper things for that as well.
@format
FIXME: xref Blocking
@end format
.

@menu
* Tape Positioning::            
* mt::                          
@end menu

@node Tape Positioning, mt, Many, Many
@subsection Tape Positions and Tape Marks
@include docwarn.texi

Just as archives can store more than one file from the file system,
tapes can store more than one archive file.  To keep track of where
archive files (or any other type of file stored on tape) begin and
end, tape archive devices write magnetic @dfn{tape marks} on the
archive media.  Tape drives write one tape mark between files,
two at the end of all the file entries.

If you think of data as a series of "0000"'s, and tape marks as "x"'s,
a tape might look like the following:

@example
0000x000000x00000x00x00000xx-------------------------
@end example

Tape devices read and write tapes using a read/write @dfn{tape
head}---a physical part of the device which can only access one point
on the tape at a time.  When you use @code{tar} to read or write
archive data from a tape device, the device will begin reading or
writing from wherever on the tape the tape head happens to be,
regardless of which archive or what part of the archive the tape head
is on.  Before writing an archive, you should make sure that no data
on the tape will be overwritten (unless it is no longer needed).
Before reading an archive, you should make sure the tape head is at
the beginning of the archive you want to read.  (The @code{restore}
script will find the archive automatically.
@format
FIXME: xref Scripted
Restoration
@end format
).
@format
FIXME: xref mt
@end format
, for an explanation of the tape moving
utility.

If you want to add new archive file entries to a tape, you should
advance the tape to the end of the existing file entries, backspace
over the last tape mark, and write the new archive file.  If you were
to add two archives to the example above, the tape might look like the
following:

@example
0000x000000x00000x00x00000x000x0000xx----------------
@end example

@node mt,  , Tape Positioning, Many
@subsection The @code{mt} Utility
@include docwarn.texi

@format
FIXME: is it true that this only works on non-block devices?  should
FIXME: explain the difference, xref to block-size (fixed or variable).
@end format

You can use the @code{mt} utility to advance or rewind a tape past a
specified number of archive files on the tape.  This will allow you to
move to the beginning of an archive before extracting or reading it,
or to the end of all the archives before writing a new one.
@format
FIXME: why isn't there an "advance 'til you find two tape marks together"? 
@end format

The syntax of the @code{mt} command is:

@example
mt [-f @var{tapename}] @var{operation} [@var{number}]
@end example

where @var{tapename} is the name of the tape device, @var{number} is
the number of times an operation is performed (with a default of one),
and @var{operation} is one of the following:

@format
FIXME: is there any use for record operations?
@end format

@table @code
@item eof
@itemx weof
Writes @var{number} tape marks at the current position on the tape.

@item fsf  
Moves tape position forward @var{number} files.

@item bsf
Moves tape position back @var{number} files.

@item rewind
Rewinds the tape. (Ignores @var{number}).

@item offline
@itemx rewoff1
Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).

@item status
Prints status information about the tape unit.
@end table
@format
FIXME: is there a better way to frob the spacing on the list?
@end format

If you don't specify a @var{tapename}, @code{mt} uses the environment
variable TAPE; if TAPE does not exist, @code{mt} uses the device
@file{/dev/rmt12}.

@code{mt} returns a 0 exit status when the operation(s) were
successful, 1 if the command was unrecognized, and 2 if an operation
failed.

@format
FIXME: new node on how to find an archive?
@end format
If you use @value{extract} with the @value{label} option specified,
@code{tar} will read an archive label (the tape head has to be
positioned on it) and print an error if the archive label doesn't
match the @var{archive-name} specified.  @var{archive-name} can be
any regular expression.  If the labels match, @code{tar} extracts
the archive.
@format
FIXME: xref Archive Label
@end format
.
@format
FIXME: xref Matching Format Parameters
@end format
.
@format
FIXME: fix cross references
@end format

@samp{tar --list --label} will cause @code{tar} to print the label.

@format
FIXME: program to list all the labels on a tape?
@end format

@node Using Multiple Tapes, Archive Label, Many, Media
@section Using Multiple Tapes
@include docwarn.texi

Often you might want to write a large archive, one larger than will fit
on the actual tape you are using.  In such a case, you can run multiple
@code{tar} commands, but this can be inconvenient, particularly if you
are using options like @value{exclude} or dumping entire filesystems.
Therefore, @code{tar} supports multiple tapes automatically.  

Use @value{multi-volume} on the command line, and then @code{tar} will,
when it reaches the end of the tape, prompt for another tape, and
continue the archive.  Each tape will have an independent archive, and
can be read without needing the other.  (As an exception to this, the
file that @code{tar} was archiving when it ran out of tape will usually
be split between the two archives; in this case you need to extract from
the first archive, using @value{multi-volume}, and then put in the
second tape when prompted, so @code{tar} can restore both halves of the
file.)

When prompting for a new tape, @code{tar} accepts any of the following
responses:  

@table @samp
@item ?
Request @code{tar} to explain possible responses
@item q
Request @code{tar} to exit immediately.
@item n @var{file name}
Request @code{tar} to write the next volume on the file @var{file name}.
@item !
Request @code{tar} to run a subshell.
@item y
Request @code{tar} to begin writing the next volume.
@end table

(You should only type @samp{y} after you have changed the tape;
otherwise @code{tar} will write over the volume it just finished.)

If you want more elaborate behavior than this, give @code{tar} the
@value{info-script} option.  The file @var{script-name} is expected
to be a program (or shell script) to be run instead of the normal
prompting procedure.  When the program finishes, @code{tar} will
immediately begin writing the next volume.  The behavior of the
@samp{n} response to the normal tape-change prompt is not available
if you use @value{info-script}.

The method @code{tar} uses to detect end of tape is not perfect, and
fails on some operating systems or on some devices.  You can use the
@value{tape-length} option if @code{tar} can't detect the end of the
tape itself.  The @var{size} argument should be the size of the tape.

The volume number used by @code{tar} in its tape-change prompt
can be changed; if you give the @value{volno-file} option, then
@var{file-of-number} should contain a decimal number.  That number
will be used as the volume number of the first volume written.
When @code{tar} is finished, it will rewrite the file with the
now-current volume number.  (This does not change the volume number
written on a tape label (
@format
FIXME: pxref Special Options for Archiving
@end format
; it
@emph{only} affects the number used in the prompt.)

If you want @code{tar} to cycle through a series of tape drives, then
you can use the @samp{n} response to the tape-change prompt.  This is
error prone, however, and doesn't work at all with @value{info-script}.
Therefore, if you give @code{tar} multiple @value{file} options, then
the specified files will be used, in sequence, as the successive volumes
of the archive.  Only when the first one in the sequence needs to be
used again will @code{tar} prompt for a tape change (or run the info
script).  

Multi-volume archives

With @value{multi-volume}, @code{tar} will not abort when it cannot
read or write any more data.  Instead, it will ask you to prepare a new
volume.  If the archive is on a magnetic tape, you should change tapes
now; if the archive is on a floppy disk, you should change disks, etc.

Each volume of a multi-volume archive is an independent @code{tar}
archive, complete in itself.  For example, you can list or extract any
volume alone; just don't specify @value{multi-volume}.  However, if one
file in the archive is split across volumes, the only way to extract
it successfully is with a multi-volume extract command @samp{--extract
--multi-volume} (@samp{-xM}) starting on or before the volume where
the file begins.

@menu
* Multi-Volume Archives::       
* Tape Files::                  
@end menu

@node Multi-Volume Archives, Tape Files, Using Multiple Tapes, Using Multiple Tapes
@subsection Archives Longer than One Tape or Disk
@cindex Multi-volume archives
@include docwarn.texi

To create an archive that is larger than will fit on a single unit of
the media, use the @value{multi-volume} option in conjunction with the
@value{create} option (
@format
FIXME: pxref Creating Archives
@end format
).  A
@dfn{multi-volume} archive can be manipulated like any other archive
(provided the @value{multi-volume} option is specified), but is stored
on more than one tape or disk.

When you specify @value{multi-volume}, @code{tar} does not report an
error when it comes to the end of an archive volume (when reading), or
the end of the media (when writing).  Instead, it prompts you to load
a new storage volume.  If the archive is on a magnetic tape, you
should change tapes when you see the prompt; if the archive is on a
floppy disk, you should change disks; etc.

You can read each individual volume of a multi-volume archive as if it
were an archive by itself.  For example, to list the contents of one
volume, use @value{list}, without @value{multi-volume} specified.
To extract an archive member from one volume (assuming it is described
that volume), use @value{extract}, again without
@value{multi-volume}.

If an archive member is split across volumes (ie. its entry begins on
one volume of the media and ends on another), you need to specify
@value{multi-volume} to extract it successfully.  In this case, you
should load the volume where the archive member starts, and use
@samp{tar --extract --multi-volume}---@code{tar} will prompt for later
volumes as it needs them.
@format
FIXME: xref Extracting From Archives
@end format
for more
information about extracting archives.

@value{info-script} is like @value{multi-volume}, except that
@code{tar} does not prompt you directly to change media volumes when
a volume is full---instead, @code{tar} runs commands you have stored
in @var{script-name}.  This option can be used to broadcast messages
such as @samp{Someone please come change my tape} when performing
unattended backups.  When @var{script-name} is done, @code{tar} will
assume that the media has been changed.

@format
FIXME: There should be a sample program here, including an exit before
FIXME: end.
@end format

@table @samp
@item --multi-volume
@itemx -M
Creates a multi-volume archive, when used in conjunction with
@value{create}.  To perform any other operation on a multi-volume
archive, specify @value{multi-volume} in conjunction with that
operation.

@item --info-script=@var{program-file}
@itemx -F @var{program-file}
Creates a multi-volume archive via a script.  Used in conjunction with
@value{create}.
@end table

@node Tape Files,  , Multi-Volume Archives, Using Multiple Tapes
@subsection Tape Files
@include docwarn.texi

When @code{tar} writes an archive to tape, it creates a single tape
file.  If multiple archives are written to the same tape, one after the
other, they each get written as separate tape files.  When extracting,
it is necessary to position the tape at the right place before running
@code{tar}.  To do this, use the @code{mt} command.  For more
information on the @code{mt} command and on the organization of tapes
into a sequence of tape files.
@format
FIXME: see ***.
@end format

@node Archive Label,  , Using Multiple Tapes, Media
@section Including a Label in the Archive
@cindex Labeling an archive
@cindex Labels on the archive media
@include docwarn.texi

@format
FIXME: Should the arg to --label be a quoted string??  no - ringo
@end format
To avoid problems caused by misplaced paper labels on the archive
media, you can include a @dfn{label} entry---an archive member which
contains the name of the archive---in the archive itself.  Use the
@value{label} option in conjunction with the @value{create} operation
to include a label entry in the archive as it is being created.

If you create an archive using both @value{label} and
@value{multi-volume}, each volume of the archive will have an
archive label of the form @samp{@var{archive-label} Volume @var{n}},
where @var{n} is 1 for the first volume, 2 for the next, and so on.

@format
FIXME: xref Multi-Volume Archives
@end format
, for information on creating multiple
volume archives.

If you extract an archive using @value{label}, @code{tar} will print
an error if the archive label doesn't match the @var{archive-label}
specified, and will then not extract the archive.  You can include
a regular expression in @var{archive-label}, in this case only.
@format
FIXME: why is a reg. exp. useful here?  (to limit extraction to a
FIXME: specific group?  ie for multi-volume???
@end format

To find out an archive's label entry (or to find out if an archive has
a label at all), use @samp{tar --list --verbose}.  @code{tar} will print the
label first, and then print archive member information, as in the
example below:

@example
% tar --verbose --list --file=iamanarchive
V--------- 0/0        0 Mar  7 12:01 1992 iamalabel--Volume Header--
-rw-rw-rw- ringo/user 40 May 21 13:30 1990 iamafilename
@end example

@table @samp
@item --label=@var{archive-label}
@itemx -V @var{archive-label}
Includes an @dfn{archive-label} at the beginning of the archive when
the archive is being created, when used in conjunction with the
@value{create} option.  Checks to make sure the archive label
matches the one specified (when used in conjunction with the
@value{extract} option.
@end table
@format
FIXME: was --volume
@end format

@node Backups and Restoration, Date input formats, Media, Top
@chapter Performing Backups and Restoring Files
@include docwarn.texi

@example
.* dumps
. + what are dumps

. + different levels of dumps
.  - full dump = dump everything
.  - level 1, level 2 dumps etc, -
	A level n dump dumps everything changed since the last level
	n-1 dump (?)

. + how to use scripts for dumps  (ie, the concept)
.  - scripts to run after editing backup specs (details)

. + Backup Specs, what is it.  
.  - how to customize
.  - actual text of script  [/sp/dump/backup-specs]

. + Problems
.  - rsh doesn't work
.  - rtape isn't installed
.  - (others?)

. + the --incremental option of tar

. + tapes 
.  - write protection
.  - types of media
.   : different sizes and types, useful for different things
.  - files and tape marks
     one tape mark between files, two at end.  
.  - positioning the tape
     MT writes two at end of write, backspaces over one when writing again.  
@end example

To @dfn{back up} a file system means to create archives that contain
all the files in that file system.  Those archives can then be used to
restore any or all of those files (for instance if a disk crashes or a
file is accidently deleted).  File system @dfn{backups} are also
called @dfn{dumps}.

@menu
* Full Dumps::                  
* Inc Dumps::                   
* incremental and listed-incremental::  
* Backup Levels::               
* Backup Parameters::           
* Scripted Backups::            
* Scripted Restoration::        
@end menu

@node Full Dumps, Inc Dumps, Backups and Restoration, Backups and Restoration
@section Using @code{tar} to Perform Full Dumps
@include docwarn.texi

@cindex full dumps
@cindex dumps, full

@cindex corrupted archives
Full dumps should only be made when no other people or programs
are modifying files in the filesystem.  If files are modified while
@code{tar} is making the backup, they may not be stored properly in
the archive, in which case you won't be able to restore them if you
have to.  (Files not being modified are written with no trouble, and do
not corrupt the entire archive.)

You will want to use the @value{label} option to give the archive a
volume label, so you can tell what this archive is even if the label
falls off the tape, or anything like that.

Unless the filesystem you are dumping is guaranteed to fit on
one volume, you will need to use the @value{multi-volume} option.
Make sure you have enough tapes on hand to complete the backup.

If you want to dump each filesystem separately you will need to use
the @value{one-file-system} option to prevent @code{tar} from crossing
filesystem boundaries when storing (sub)directories.

The @value{incremental} option is not needed, since this is a complete
copy of everything in the filesystem, and a full restore from this
backup would only be done onto a completely empty disk.

Unless you are in a hurry, and trust the @code{tar} program (and your
tapes), it is a good idea to use the @value{verify} option, to make
sure your files really made it onto the dump properly.  This will
also detect cases where the file was modified while (or just after)
it was being archived.  Not all media (notably cartridge tapes) are
capable of being verified, unfortunately.

@value{listed-incremental} take a file name argument always.  If the
file doesn't exist, run a level zero dump, creating the file.  If the
file exists, uses that file to see what has changed.

@value{incremental}
@format
FIXME: look it up
@end format

@value{incremental} handle old GNU-format incremental
backup.

This option should only be used when creating an incremental backup of
a filesystem.  When the @value{incremental} option is used, @code{tar}
writes, at the beginning of the archive, an entry for each of the
directories that will be operated on.  The entry for a directory
includes a list of all the files in the directory at the time the
dump was done, and a flag for each file indicating whether the file
is going to be put in the archive.  This information is used when
doing a complete incremental restore.

Note that this option causes @code{tar} to create a non-standard
archive that may not be readable by non-GNU versions of the @code{tar}
program.

The @value{incremental} option means the archive is an incremental
backup.  Its meaning depends on the command that it modifies.

If the @value{incremental} option is used with @value{list}, @code{tar}
will list, for each directory in the archive, the list of files in
that directory at the time the archive was created.  This information
is put out in a format that is not easy for humans to read, but which
is unambiguous for a program: each file name is preceded by either a
@samp{Y} if the file is present in the archive, an @samp{N} if the
file is not included in the archive, or a @samp{D} if the file is
a directory (and is included in the archive).  Each file name is
terminated by a null character.  The last file is followed by an
additional null and a newline to indicate the end of the data.

If the @value{incremental} option is used with @value{extract}, then
when the entry for a directory is found, all files that currently
exist in that directory but are not listed in the archive @emph{are
deleted from the directory}.

This behavior is convenient when you are restoring a damaged file
system from a succession of incremental backups: it restores the
entire state of the file system to that which obtained when the backup
was made.  If you don't use @value{incremental}, the file system will
probably fill up with files that shouldn't exist any more.

@value{listed-incremental} handle new GNU-format
incremental backup.

@value{listed-incremental} acts like @value{incremental}, but when
used in conjunction with @value{create} will also cause @code{tar} to
use the file @var{file}, which contains information about the state
of the filesystem at the time of the last backup, to decide which
files to include in the archive being created.  That file will then
be updated by @code{tar}.  If the file @var{file} does not exist when
this option is specified, @code{tar} will create it, and include all
appropriate files in the archive.

The file, which is archive independent, contains the date it was last
modified and a list of devices, inode numbers and directory names.
@code{tar} will archive files with newer mod dates or inode change
times, and directories with an unchanged inode number and device but
a changed directory name.  The file is updated after the files to
be archived are determined, but before the new archive is actually
created.

@node Inc Dumps, incremental and listed-incremental, Full Dumps, Backups and Restoration
@section Using @code{tar} to Perform Incremental Dumps
@include docwarn.texi

@cindex incremental dumps
@cindex dumps, incremental

Performing incremental dumps is similar to performing full dumps,
although a few more options will usually be needed.

You will need to use the @samp{-N @var{date}} option to tell @code{tar}
to only store files that have been modified since @var{date}.
@var{date} should be the date and time of the last full/incremental
dump.

A standard scheme is to do a @emph{monthly} (full) dump once a month,
a @emph{weekly} dump once a week of everything since the last monthly
and a @emph{daily} every day of everything since the last (weekly or
monthly) dump.

Here is a copy of the script used to dump the filesystems of the
machines here at the Free Software Foundation.  This script is run via
@code{cron} late at night when people are least likely to be using the
machines.  This script dumps several filesystems from several machines
at once (via NFS).  The operator is responsible for ensuring that all
the machines will be up at the time the dump happens.  If a machine is
not running, its files will not be dumped, and the next day's
incremental dump will @emph{not} store files that would have gone onto
that dump.

@example
#!/bin/csh
# Dump thingie
set now = `date`
set then = `cat date.nfs.dump`
/u/hack/bin/tar -c -G -v\
 -f /dev/rtu20\
 -b 126\
 -N "$then"\
 -V "Dump from $then to $now"\
 /alpha-bits/gp\
 /gnu/hack\
 /hobbes/u\
 /spiff/u\
 /sugar-bombs/u
echo $now > date.nfs.dump
mt -f /dev/rtu20 rew
@end example

Output from this script is stored in a file, for the operator to
read later.

This script uses the file @file{date.nfs.dump} to store the date/time
of the last dump.

Since this is a streaming tape drive, no attempt to verify the archive
is done.  This is also why the high blocking factor (126) is used.
The tape drive must also be rewound by the @code{mt} command after
the dump is made.

@node incremental and listed-incremental, Backup Levels, Inc Dumps, Backups and Restoration
@section The Incremental Options
@include docwarn.texi

@value{incremental} is used in conjunction with @value{create},
@value{extract} or @value{list} when backing up and restoring file
systems.  An archive cannot be extracted or listed with the
@value{incremental} option specified unless it was created with the
option specified.  This option should only be used by a script, not by
the user, and is usually disregarded in favor of
@value{listed-incremental}, which is described below.

@value{incremental} in conjunction with @value{create} causes
@code{tar} to write, at the beginning of the archive, an entry for
each of the directories that will be archived.  The entry for a
directory includes a list of all the files in the directory at the
time the archive was created and a flag for each file indicating
whether or not the file is going to be put in the archive.
 
Note that this option causes @code{tar} to create a non-standard
archive that may not be readable by non-GNU versions of the @code{tar}
program.  

@value{incremental} in conjunction with @value{extract} causes
@code{tar} to read the lists of directory contents previously stored
in the archive, @emph{delete} files in the file system that did not
exist in their directories when the archive was created, and then
extract the files in the archive.

This behavior is convenient when restoring a damaged file system from
a succession of incremental backups: it restores the entire state of
the file system to that which obtained when the backup was made.  If
@value{incremental} isn't specified, the file system will probably
fill up with files that shouldn't exist any more.

@value{incremental} in conjunction with @value{list}, causes 
@code{tar} to print, for each directory in the archive, the list of
files in that directory at the time the archive was created.  This
information is put out in a format that is not easy for humans to
read, but which is unambiguous for a program: each file name is
preceded by either a @samp{Y} if the file is present in the archive,
an @samp{N} if the file is not included in the archive, or a @samp{D}
if the file is a directory (and is included in the archive).  Each
file name is terminated by a null character.  The last file is followed
by an additional null and a newline to indicate the end of the data.

@value{listed-incremental} acts like @value{incremental}, but when
used in conjunction with @value{create} will also cause @code{tar}
to use the file @var{snapshot-file}, which contains information about
the state of the file system at the time of the last backup, to decide
which files to include in the archive being created.  That file will
then be updated by @code{tar}.  If the file @var{file} does not exist
when this option is specified, @code{tar} will create it, and include
all appropriate files in the archive.

The file @var{file}, which is archive independent, contains the date
it was last modified and a list of devices, inode numbers and
directory names.  @code{tar} will archive files with newer mod dates
or inode change times, and directories with an unchanged inode number
and device but a changed directory name.  The file is updated after
the files to be archived are determined, but before the new archive is
actually created.

@format
FIXME: this section needs to be written
@end format

@node Backup Levels, Backup Parameters, incremental and listed-incremental, Backups and Restoration
@section Levels of Backups
@include docwarn.texi

An archive containing all the files in the file system is called a
@dfn{full backup} or @dfn{full dump}.  You could insure your data by
creating a full dump every day.  This strategy, however, would waste a
substantial amount of archive media and user time, as unchanged files
are daily re-archived.

It is more efficient to do a full dump only occasionally.  To back up
files between full dumps, you can a incremental dump.  A @dfn{level
one} dump archives all the files that have changed since the last full
dump.

A typical dump strategy would be to perform a full dump once a week,
and a level one dump once a day.  This means some versions of files
will in fact be archived more than once, but this dump strategy makes
it possible to restore a file system to within one day of accuracy by
only extracting two archives---the last weekly (full) dump and the
last daily (level one) dump.  The only information lost would be in
files changed or created since the last daily backup.  (Doing dumps
more than once a day is usually not worth the trouble).

GNU @code{tar} comes with scripts you can use to do full and level-one
dumps.  Using scripts (shell programs) to perform backups and
restoration is a convenient and reliable alternative to typing out
file name lists and @code{tar} commands by hand.

Before you use these scripts, you need to edit the file
@file{backup-specs}, which specifies parameters used by the backup
scripts and by the restore script.
@format
FIXME: xref Script Syntax
@end format
.
Once the backup parameters are set, you can perform backups or
restoration by running the appropriate script.  

The name of the restore script is @code{restore}. The names of the
level one and full backup scripts are, respectively, @code{level-1} and
@code{level-0}.  The @code{level-0} script also exists under the name
@code{weekly}, and the @code{level-1} under the name
@code{daily}---these additional names can be changed according to your
backup schedule.
@format
FIXME: xref Scripted Restoration
@end format
, for more information
on running the restoration script.
@format
FIXME: xref Scripted Backups
@end format
, for more
information on running the backup scripts.

@emph{Please Note:} The backup scripts and the restoration scripts are
designed to be used together.  While it is possible to restore files
by hand from an archive which was created using a backup script, and
to create an archive by hand which could then be extracted using the
restore script, it is easier to use the scripts.
@format
FIXME: xref incremental
and listed-incremental
@end format
, before making such an attempt.

@format
FIXME: shorten node names
@end format

@node Backup Parameters, Scripted Backups, Backup Levels, Backups and Restoration
@section Setting Parameters for Backups and Restoration
@include docwarn.texi

The file @file{backup-specs} specifies backup parameters for the
backup and restoration scripts provided with @code{tar}.  You must
edit @file{backup-specs} to fit your system configuration and schedule
before using these scripts.

@format
FIXME: This about backup scripts needs to be written: BS is a shell
FIXME: script ....  thus ... @file{backup-specs} is in shell script
FIXME: syntax.  xref Script Syntax, for an explanation of this syntax.
FIXME: 
FIXME: whats a parameter ....  looked at by the backup scripts ... which
FIXME: will be expecting to find ... now syntax ... value is linked to
FIXME: lame ...  @file{backup-specs} specifies the following parameters:
@end format

@table @code
@item ADMINISTRATOR
The user name of the backup administrator.

@item BACKUP_HOUR
The hour at which the backups are done.  This can be a number from 0
to 23, or the string @samp{now}.

@item TAPE_FILE
The device @code{tar} writes the archive to.  This device should be
attached to the host on which the dump scripts are run.
@format
FIXME: examples for all  ...
@end format

@item TAPE_STATUS
The command to use to obtain the status of the archive device,
including error count.  On some tape drives there may not be such a
command; in that case, simply use `TAPE_STATUS=false'.

@item BLOCKING
The blocking factor @code{tar} will use when writing the dump archive.

@format
FIXME: xref Blocking Factor
@end format
.

@item BACKUP_DIRS
A list of file systems to be dumped.  You can include any directory
name in the list---subdirectories on that file system will be
included, regardless of how they may look to other networked machines.
Subdirectories on other file systems will be ignored.

The host name specifies which host to run @code{tar} on, and should
normally be the host that actually contains the file system.  However,
the host machine must have GNU @code{tar} installed, and must be able
to access the directory containing the backup scripts and their
support files using the same file name that is used on the machine
where the scripts are run (ie. what @code{pwd} will print when in that
directory on that machine).  If the host that contains the file system
does not have this capability, you can specify another host as long as
it can access the file system through NFS.

@item BACKUP_FILES
A list of individual files to be dumped.  These should be accessible
from the machine on which the backup script is run.  
@format
FIXME: same file name, be specific.  through nfs ...
@end format
@end table

@menu
* backup-specs example::        
* Script Syntax::               
@end menu

@node backup-specs example, Script Syntax, Backup Parameters, Backup Parameters
@subsection An Example Text of @file{Backup-specs}
@include docwarn.texi

The following is the text of @file{backup-specs} as it appears at FSF:

@example
# site-specific parameters for file system backup.

ADMINISTRATOR=friedman
BACKUP_HOUR=1
TAPE_FILE=/dev/nrsmt0
TAPE_STATUS="mts -t $TAPE_FILE"
BLOCKING=124
BACKUP_DIRS="
	albert:/fs/fsf
	apple-gunkies:/gd
	albert:/fs/gd2
	albert:/fs/gp
	geech:/usr/jla
	churchy:/usr/roland
	albert:/
	albert:/usr
	apple-gunkies:/
	apple-gunkies:/usr
	gnu:/hack
	gnu:/u
	apple-gunkies:/com/mailer/gnu
	apple-gunkies:/com/archive/gnu"

BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"

@end example

@node Script Syntax,  , backup-specs example, Backup Parameters
@subsection Syntax for @file{Backup-specs}
@include docwarn.texi

@file{backup-specs} is in shell script syntax.  The following
conventions should be considered when editing the script:
@format
FIXME: "conventions?"
@end format

A quoted string is considered to be contiguous, even if it is on more
than one line.  Therefore, you cannot include commented-out lines
within a multi-line quoted string.  BACKUP_FILES and BACKUP_DIRS are
the two most likely parameters to be multi-line.

A quoted string typically cannot contain wildcards.  In
@file{backup-specs}, however, the parameters BACKUP_DIRS and
BACKUP_FILES can contain wildcards.

@node Scripted Backups, Scripted Restoration, Backup Parameters, Backups and Restoration
@section Using the Backup Scripts
@include docwarn.texi

The syntax for running a backup script is:

@example
@file{script-name} [@var{time-to-be-run}]
@end example

where @var{time-to-be-run} can be a specific system time, or can be
@kbd{now}.  If you do not specify a time, the script runs at the time
specified in @file{backup-specs} (
@format
FIXME: pxref Script Syntax
@end format
).

You should start a script with a tape or disk mounted.  Once you start
a script, it prompts you for new tapes or disks as it needs them.
Media volumes don't have to correspond to archive files---a
multi-volume archive can be started in the middle of a tape that
already contains the end of another multi-volume archive.  The
@code{restore} script prompts for media by its archive volume, so to
avoid an error message you should keep track of which tape (or disk)
contains which volume of the archive.
@format
FIXME: xref Scripted Restoration
@end format
.

@format
FIXME: have file names changed?
@end format
The backup scripts write two files on the file system.  The first is a
record file in @file{/etc/tar-backup/}, which is used by the scripts
to store and retrieve information about which files were dumped.  This
file is not meant to be read by humans, and should not be deleted by
them.
@format
FIXME: xref incremental and listed-incremental
@end format
, for a more
detailed explanation of this file.

The second file is a log file containing the names of the file systems
and files dumped, what time the backup was made, and any error
messages that were generated, as well as how much space was left in
the media volume after the last volume of the archive was written.
You should check this log file after every backup.  The file name is
@file{log-@var{mmm-ddd-yyyy}-level-1} or
@file{log-@var{mmm-ddd-yyyy}-full}.

The script also prints the name of each system being dumped to the
standard output.
@format
FIXME: the section on restore scripts is commented out.
FIXME: a section on non-scripted testore mya be a good idea
@end format

@node Scripted Restoration,  , Scripted Backups, Backups and Restoration
@section Using the Restore Script
@format
FIXME: subject to change as things develop
@end format
@include docwarn.texi

(This node was @@ignore'd---merely listing it for now.)

To restore files that were archived using a scripted backup, use the
@code{restore} script.  The syntax for the script is:


where ***** are the file systems to restore from, and
***** is a regular expression which specifies which files to
restore.  If you specify --all, the script restores all the files
in the file system.

You should start the restore script with the media containing the
first volume of the archive mounted.  The script will prompt for other
volumes as they are needed.  If the archive is on tape, you don't need
to rewind the tape to to its beginning---if the tape head is
positioned past the beginning of the archive, the script will rewind
the tape as needed.
@format
FIXME: xref Media
@end format
, for a discussion of tape
positioning.

If you specify @samp{--all} as the @var{files} argument, the
@code{restore} script extracts all the files in the archived file
system into the active file system.  

@quotation
@strong{Warning:}The script will delete files from the active file
system if they were not in the file system when the archive was made.
@end quotation


@format
FIXME: xref incremental and listed-incremental
@end format
, for an explanation of how
the script makes that determination.
@format
FIXME: this may be an option, not a given
@end format

@node Date input formats, Archive Format, Backups and Restoration, Top
@chapter Date input formats

@cindex date input formats
@findex getdate

This section describes the textual date representations that GNU
programs accept.  These are the strings you, as a user, can supply as
arguments to the various programs.  The C interface (via the
@code{getdate} function) is not described here.

@cindex beginning of time, for Unix
@cindex epoch, for Unix
Although the date syntax here can represent any possible time since zero
A.D., computer integers are not big enough for such a (comparatively)
long time.  The earliest date semantically allowed on Unix systems is
midnight, 1 January 1970 UCT.

@menu
* General date syntax::         
* Calendar date item::          
* Time of day item::            
* Timezone item::               
* Day of week item::            
* Relative item in date strings::  
* Pure numbers in date strings::  
* Authors of getdate::          
@end menu

@node General date syntax, Calendar date item, Date input formats, Date input formats
@section General date syntax

@cindex general date syntax

@cindex items in date strings
A @dfn{date} is a string, possibly empty, containing many items
separated by whitespace.  The whitespace may be omitted when no
ambiguity arises.  The empty string means the beginning of today (i.e.,
midnight).  Order of the items is immaterial.  A date string may contain
many flavors of items:

@itemize @bullet
@item calendar date items
@item time of the day items
@item time zone items
@item day of the week items
@item relative items
@item pure numbers.  
@end itemize

@noindent We describe each of these item types in turn, below.

@cindex numbers, written-out
@cindex ordinal numbers
@findex first @r{in date strings}
@findex next @r{in date strings}
@findex last @r{in date strings}
A few numbers may be written out in words in most contexts.  This is
most useful for specifying day of the week items or relative items (see
below).  Here is the list: @samp{first} for 1, @samp{next} for 2,
@samp{third} for 3, @samp{fourth} for 4, @samp{fifth} for 5,
@samp{sixth} for 6, @samp{seventh} for 7, @samp{eighth} for 8,
@samp{ninth} for 9, @samp{tenth} for 10, @samp{eleventh} for 11 and
@samp{twelfth} for 12.  Also, @samp{last} means exactly @math{-1}.

@cindex months, written-out
When a month is written this way, it is still considered to be written
numerically, instead of being ``spelled in full''; this changes the
allowed strings.

@cindex case, ignored in dates
@cindex comments, in dates
Alphabetic case is completely ignored in dates.  Comments may be introduced
between round parentheses, as long as included parentheses are properly
nested.  Hyphens not followed by a digit are currently ignored.  Leading
zeros on numbers are ignored.

@node Calendar date item, Time of day item, General date syntax, Date input formats
@section Calendar date item

@cindex calendar date item

A @dfn{calendar date item} specifies a day of the year.  It is 
specified differently, depending on whether the month is specified
numerically or literally.  All these strings specify the same calendar date:

@example
1970-9-17            # ISO 8601.
70-9-17              # This century assumed by default.
70-09-17             # Leading zeros are ignored.
9/17/72              # Common U.S. writing.
24 September 1972
24 Sept 72           # September has a special abbreviation.
24 Sep 72            # Three-letter abbreviations always allowed.
Sep 24, 1972
24-sep-72
24sep72
@end example

The year can also be omitted.  In this case, the last specified year is
used, or the current year if none.  For example:

@example
9/17
sep 17
@end example

Here are the rules.

@cindex ISO 8601 date format
@cindex date format, ISO 8601
For numeric months, the ISO 8601 format
@samp{@var{year}-@var{month}-@var{day}} is allowed, where @var{year} is
any positive number, @var{month} is a number between 1 and 12, and
@var{day} is a number between 1 and 31.  If @var{year} is less than 100,
then 1900 is added to it to force a date in this century.  The construct
@samp{@var{month}/@var{day}/@var{year}}, popular in the United States,
is accepted.  Also @samp{@var{month}/@var{day}}, omitting the year.

@cindex month names in date strings
@cindex abbreviations for months
Literal months may be spelled out in full: @samp{January},
@samp{February}, @samp{March}, @samp{April}, @samp{May}, @samp{June},
@samp{July}, @samp{August}, @samp{September}, @samp{October},
@samp{November} or @samp{December}.  Literal months may be abbreviated
to their first three letters, possibly followed by an abbreviating dot.
It is also permitted to write @samp{Sept} instead of @samp{September}.

When months are written literally, the calendar date may be given as any
of the following:

@example
@var{day} @var{month} @var{year}
@var{day} @var{month}
@var{month} @var{day} @var{year}
@var{day}-@var{month}-@var{year}
@end example

Or, omitting the year:

@example
@var{month} @var{day}
@end example

@node Time of day item, Timezone item, Calendar date item, Date input formats
@section Time of day item

@cindex time of day item

A @dfn{time of day item} in date strings specifies the time on a given
day.  Here are some examples, all of which represent the same time:

@example
20:02:0
20:02
8:02pm
20:02-0500      # In EST (Eastern U.S. Standard Time).
@end example

More generally, the time of the day may be given as
@samp{@var{hour}:@var{minute}:@var{second}}, where @var{hour} is
a number between 0 and 23, @var{minute} is a number between 0 and
59, and @var{second} is a number between 0 and 59.  Alternatively,
@samp{:@var{second}} can be omitted, in which case it is taken to
be zero.

@findex am @r{in date strings}
@findex pm @r{in date strings}
@findex midnight @r{in date strings}
@findex noon @r{in date strings}
If the time is followed by @samp{am} or @samp{pm} (or @samp{a.m.}
or @samp{p.m.}), @var{hour} is restricted to run from 1 to 12, and
@samp{:@var{minute}} may be omitted (taken to be zero).  @samp{am}
indicates the first half of the day, @samp{pm} indicates the second
half of the day.  In this notation, 12 is the predecessor of 1:
midnight is @samp{12am} while noon is @samp{12pm}.

@cindex timezone correction
@cindex minutes, timezone correction by
The time may alternatively be followed by a timezone correction,
expressed as @samp{@var{s}@var{hh}@var{mm}}, where @var{s} is @samp{+}
or @samp{-}, @var{hh} is a number of zone hours and @var{mm} is a number
of zone minutes.  When a timezone correction is given this way, it
forces interpretation of the time in UTC, overriding any previous
specification for the timezone or the local timezone.  The @var{minute}
part of the time of the day may not be elided when a timezone correction
is used.  This is the only way to specify a timezone correction by
fractional parts of an hour.

Either @samp{am}/@samp{pm} or a timezone correction may be specified,
but not both.

@node Timezone item, Day of week item, Time of day item, Date input formats
@section Timezone item

@cindex timezone item

A @dfn{timezone item} specifies an international timezone, indicated by
a small set of letters.  Any included period is ignored.  Military
timezone designations use a single letter.  Currently, only integral
zone hours may be represented in a timezone item.  See the previous
section for a finer control over the timezone correction.

Here are many non-daylight-savings-time timezones, indexed by the zone
hour value.

@table @asis
@item +000
@cindex Greenwich Mean Time
@cindex Universal Coordinated Time
@cindex Western European Time
@samp{GMT} for Greenwich Mean, @samp{UT} or @samp{UTC} for Universal
(Coordinated), @samp{WET} for Western European and @samp{Z} for
militaries.
@item +100
@cindex West African Time
@samp{WAT} for West Africa and
@samp{A} for militaries.
@item +200
@cindex Azores Time
@samp{AT} for Azores and @samp{B} for militaries.
@item +300
@samp{C} for militaries.
@item +400
@cindex Atlantic Standard Time
@samp{AST} for Atlantic Standard and @samp{D} for militaries.
@item +500
@cindex Eastern Standard Time
@samp{E} for militaries and @samp{EST} for Eastern Standard.
@item +600
@cindex Central Standard Time
@samp{CST} for Central Standard and @samp{F} for militaries.
@item +700
@cindex Mountain Standard Time
@samp{G} for militaries and @samp{MST} for Mountain Standard.
@item +800
@cindex Pacific Standard Time
@samp{H} for militaries and @samp{PST} for Pacific Standard.
@item +900
@cindex Yukon Standard Time
@samp{I} for militaries and @samp{YST} for Yukon Standard.
@item +1000
@cindex Alaska-Hawaii Time
@cindex Central Alaska Time
@cindex Hawaii Standard Time
@samp{AHST} for Alaska-Hawaii Standard, @samp{CAT} for Central Alaska,
@samp{HST} for Hawaii Standard and @samp{K} for militaries.
@item +1100
@cindex Nome Standard Time
@samp{L} for militaries and @samp{NT} for Nome.
@item +1200
@cindex International Date Line West
@samp{IDLW} for International Date Line West and @samp{M} for
militaries.
@item -100
@cindex Central European Time
@cindex Middle European Time
@cindex Middle European Winter Time
@cindex French Winter Time
@cindex Swedish Winter Time
@samp{CET} for Central European, @samp{FWT} for French Winter,
@samp{MET} for Middle European, @samp{MEWT} for Middle European
Winter, @samp{N} for militaries and @samp{SWT} for Swedish Winter.
@item -200
@cindex Eastern European Time
@cindex USSR Zone
@samp{EET} for Eastern European, USSR Zone 1 and @samp{O} for militaries.
@item -300
@cindex Baghdad Time
@samp{BT} for Baghdad, USSR Zone 2 and @samp{P} for militaries.
@item -400
@samp{Q} for militaries and @samp{ZP4} for USSR Zone 3.
@item -500
@samp{R} for militaries and @samp{ZP5} for USSR Zone 4.
@item -600
@samp{S} for militaries and @samp{ZP6} for USSR Zone 5.
@item -700
@cindex West Australian Standard Time
@samp{T} for militaries and @samp{WAST} for West Australian Standard.
@item -800
@cindex China Coast Time
@samp{CCT} for China Coast, USSR Zone 7 and @samp{U} for militaries.
@item -900
@cindex Japan Standard Time
@samp{JST} for Japan Standard, USSR Zone 8 and @samp{V} for militaries.
@item -1000
@cindex East Australian Standard Time
@cindex Guam Standard Time
@samp{EAST} for East Australian Standard, @samp{GST} for Guam
Standard, USSR Zone 9 and @samp{W} for militaries.
@item -1100
@samp{X} for militaries.
@item -1200
@cindex International Date Line East
@cindex New Zealand Standard Time
@samp{IDLE} for International Date Line East, @samp{NZST} for
New Zealand Standard, @samp{NZT} for New Zealand and @samp{Y} for
militaries.
@end table

@cindex daylight savings time
Here are many DST timezones, indexed by the zone hour value.  Also, by
following a non-DST timezone by the string @samp{DST} in a separate word
(that is, separated by some whitespace), the corresponding DST timezone
may be specified.

@table @asis
@item 0
@samp{BST} for British Summer.
@item +400
@samp{ADT} for Atlantic Daylight.
@item +500
@samp{EDT} for Eastern Daylight.
@item +600
@samp{CDT} for Central Daylight.
@item +700
@samp{MDT} for Mountain Daylight.
@item +800
@samp{PDT} for Pacific Daylight.
@item +900
@samp{YDT} for Yukon Daylight.
@item +1000
@samp{HDT} for Hawaii Daylight.
@item -100
@samp{MEST} for Middle European Summer, @samp{MESZ} for Middle European
Summer, @samp{SST} for Swedish Summer and @samp{FST} for French Summer.
@item -700
@samp{WADT} for West Australian Daylight.
@item -1000
@samp{EADT} for Eastern Australian Daylight.
@item -1200
@samp{NZDT} for New Zealand Daylight.
@end table

@node Day of week item, Relative item in date strings, Timezone item, Date input formats
@section Day of week item

@cindex day of week item

The explicit mention of a day of the week will forward the date
(only if necessary) to reach that day of the week in the future.

Days of the week may be spelled out in full: @samp{Sunday},
@samp{Monday}, @samp{Tuesday}, @samp{Wednesday}, @samp{Thursday},
@samp{Friday} or @samp{Saturday}.  Days may be abbreviated to their
first three letters, optionally followed by a period.  The special
abbreviations @samp{Tues} for @samp{Tuesday}, @samp{Wednes} for
@samp{Wednesday} and @samp{Thur} or @samp{Thurs} for @samp{Thursday} are
also allowed.

@findex next @var{day}
@findex last @var{day}
A number may precede a day of the week item to move forward
supplementary weeks.  It is best used in expression like @samp{third
monday}.  In this context, @samp{last @var{day}} or @samp{next
@var{day}} is also acceptable; they move one week before or after
the day that @var{day} by itself would represent.

A comma following a day of the week item is ignored.

@node Relative item in date strings, Pure numbers in date strings, Day of week item, Date input formats
@section Relative item in date strings

@cindex relative items in date strings
@cindex displacement of dates

@dfn{Relative items} adjust a date (or the current date if none) forward
or backward.  The effect of relative items accumulate.  Here are some
examples:

@example
1 year
1 year ago
3 years
2 days
@end example

@findex year @r{in date strings}
@findex month @r{in date strings}
@findex fortnight @r{in date strings}
@findex week @r{in date strings}
@findex day @r{in date strings}
@findex hour @r{in date strings}
@findex minute @r{in date strings}
The unit of time displacement may be selected by the string @samp{year}
or @samp{month} for moving by whole years or months.  These are fuzzy
units, as years and months are not all of equal duration.  More precise
units are @samp{fortnight} which is worth 14 days, @samp{week} worth 7
days, @samp{day} worth 24 hours, @samp{hour} worth 60 minutes,
@samp{minute} or @samp{min} worth 60 seconds, and @samp{second} or
@samp{sec} worth one second.  An @samp{s} suffix on these units is
accepted and ignored.

@findex ago @r{in date strings}
The unit of time may be preceded by a multiplier, given as an optionally
signed number.  Unsigned numbers are taken as positively signed.  No
number at all implies 1 for a multiplier.  Following a relative item by
the string @samp{ago} is equivalent to preceding the unit by a
multiplicator with value @math{-1}.

@findex day @r{in date strings}
@findex tomorrow @r{in date strings}
@findex yesterday @r{in date strings}
The string @samp{tomorrow} is worth one day in the future (equivalent
to @samp{day}), the string @samp{yesterday} is worth
one day in the past (equivalent to @samp{day ago}).

@findex now @r{in date strings}
@findex today @r{in date strings}
@findex this @r{in date strings}
The strings @samp{now} or @samp{today} are relative items corresponding
to zero-valued time displacement, these strings come from the fact
a zero-valued time displacement represents the current time when not
otherwise change by previous items.  They may be used to stress other
items, like in @samp{12:00 today}.  The string @samp{this} also has
the meaning of a zero-valued time displacement, but is preferred in
date strings like @samp{this thursday}.

When a relative item makes the resulting date to cross the boundary
between DST and non-DST (or vice-versa), the hour is adjusted according
to the local time.

@node Pure numbers in date strings, Authors of getdate, Relative item in date strings, Date input formats
@section Pure numbers in date strings

@cindex pure numbers in date strings

The precise intepretation of a pure decimal number is dependent of
the context in the date string.

If the decimal number is of the form @var{yyyy}@var{mm}@var{dd} and no
other calendar date item (
@format
FIXME: pxref Calendar date item
@end format
) appears before it
in the date string, then @var{yyyy} is read as the year, @var{mm} as the
month number and @var{dd} as the day of the month, for the specified
calendar date.

If the decimal number is of the form @var{hh}@var{mm} and no other time
of day item appears before it in the date string, then @var{hh} is read
as the hour of the day and @var{mm} as the minute of the hour, for the
specified time of the day.  @var{mm} can also be omitted.

If both a calendar date and a time of day appear to the left of a number
in the date string, but no relative item, then the number overrides the
year.

@node Authors of getdate,  , Pure numbers in date strings, Date input formats
@section Authors of @code{getdate}

@cindex authors of @code{getdate}

@cindex Bellovin, Steven M.
@cindex Salz, Rich
@cindex Berets, Jim
@cindex MacKenzie, David
@cindex Meyering, Jim
@code{getdate} was originally implemented by Steven M. Bellovin
(@samp{smb@@research.att.com}) while at the University of North Carolina
at Chapel Hill.  The code was later tweaked by a couple of people on
Usenet, then completely overhauled by Rich $alz (@samp{rsalz@@bbn.com})
and Jim Berets (@samp{jberets@@bbn.com}) in August, 1990.  Various
revisions for the GNU system were made by David MacKenzie, Jim Meyering,
and others.

@cindex Pinard, F.
@cindex Berry, K.
This chapter was originally produced by @value{Francois} Pinard
(@samp{pinard@@iro.umontreal.ca}) from the @file{getdate.y} source code,
and then edited by K.@: Berry (@samp{kb@@cs.umb.edu}).

@node Archive Format, Index, Date input formats, Top
@chapter Format of @code{tar} archives
@include docwarn.texi

@menu
* Standard::                    
* Extensions::                  
* cpio::                        
@end menu

@node Standard, Extensions, Archive Format, Archive Format
@section The Standard Format
@include docwarn.texi

A @code{tar} archive file contains a series of records.  Each record
contains @code{RECORDSIZE} bytes.  Although this format may be thought
of as being on magnetic tape, other media are often used.

Each file archived is represented by a header record which describes
the file, followed by zero or more records which give the contents
of the file.  At the end of the archive file there may be a record
filled with binary zeros as an end-of-file marker.  A reasonable system
should write a record of zeros at the end, but must not assume that
such a record exists when reading an archive.

The records may be @dfn{blocked} for physical I/O operations.
Each block of @var{n} records (where @var{n} is set by the
@value{block-size} option to @code{tar}) is written with a single
@w{@samp{write ()}} operation.  On magnetic tapes, the result of
such a write is a single tape record.  When writing an archive,
the last block of records should be written at the full size, with
records after the zero record containing all zeroes.  When reading
an archive, a reasonable system should properly handle an archive
whose last block is shorter than the rest, or which contains garbage
records after a zero record.

The header record is defined in C as follows.  In the GNU @code{tar}
distribution, this is part of file @file{src/tar.h}:

@example
@include header.texi
@end example

All characters in header records are represented by using 8-bit
characters in the local variant of ASCII.  Each field within the
structure is contiguous; that is, there is no padding used within
the structure.  Each character on the archive medium is stored
contiguously.

Bytes representing the contents of files (after the header record
of each file) are not translated in any way and are not constrained
to represent characters in any character set.  The @code{tar} format
does not distinguish text files from binary files, and no translation
of file contents is performed.

The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
@code{gname} are null-terminated character strings.  All other fileds
are zero-filled octal numbers in ASCII.  Each numeric field of width
@var{w} contains @var{w} minus 2 digits, a space, and a null, except
@code{size}, and @code{mtime}, which do not contain the trailing null.

The @code{name} field is the file name of the file, with directory names
(if any) preceding the file name, separated by slashes.
@format
FIXME: how big a name before field overflows?
@end format

The @code{mode} field provides nine bits specifying file permissions
and three bits to specify the Set UID, Set GID, and Save Text
(@dfn{sticky}) modes.  Values for these bits are defined above.
When special permissions are required to create a file with a given
mode, and the user restoring files from the archive does not hold such
permissions, the mode bit(s) specifying those special permissions
are ignored.  Modes which are not supported by the operating system
restoring files from the archive will be ignored.  Unsupported modes
should be faked up when creating or updating an archive; e.g. the
group permission could be copied from the @emph{other} permission.

The @code{uid} and @code{gid} fields are the numeric user and group
ID of the file owners, respectively.  If the operating system does
not support numeric user or group IDs, these fields should be ignored.

The @code{size} field is the size of the file in bytes; linked files
are archived with this field specified as zero.
@format
FIXME: xref Modifiers
@end format
, in
particular the @value{incremental} option.

The @code{mtime} field is the modification time of the file at the time
it was archived.  It is the ASCII representation of the octal value of
the last time the file was modified, represented as an integer number of
seconds since January 1, 1970, 00:00 Coordinated Universal Time.

The @code{chksum} field is the ASCII representation of the octal value
of the simple sum of all bytes in the header record.  Each 8-bit
byte in the header is added to an unsigned integer, initialized to
zero, the precision of which shall be no less than seventeen bits.
When calculating the checksum, the @code{chksum} field is treated as
if it were all blanks.

The @code{typeflag} field specifies the type of file archived.  If a
particular implementation does not recognize or permit the specified
type, the file will be extracted as if it were a regular file.  As this
action occurs, @code{tar} issues a warning to the standard error.

The @code{atime} and @code{ctime} fields are used in making incremental
backups; they store, respectively, the particular file's access time
and last inode-change time.

The @code{offset} is used by the @value{multi-volume} option, when
making a multi-volume archive.  The offset is number of bytes into
the file that we need to restart at to continue the file on the next
tape, i.e., where we store the location that a continued file is
continued at.

The following fields were added to deal with sparse files.  A file
is @dfn{sparse} if it takes in unallocated blocks which end up being
represented as zeros, i.e., no useful data.  A test to see if a file
is sparse is to look at the number blocks allocated for it versus the
number of characters in the file; if there are fewer blocks allocated
for the file than would normally be allocated for a file of that
size, then the file is sparse.  This is the method @code{tar} uses to
detect a sparse file, and once such a file is detected, it is treated
differently from non-sparse files.

Sparse files are often @code{dbm} files, or other database-type files
which have data at some points and emptiness in the greater part of
the file.  Such files can appear to be very large when an @samp{ls
-l} is done on them, when in truth, there may be a very small amount
of important data contained in the file.  It is thus undesirable
to have @code{tar} think that it must back up this entire file, as
great quantities of room are wasted on empty blocks, which can lead
to running out of room on a tape far earlier than is necessary.
Thus, sparse files are dealt with so that these empty blocks are
not written to the tape.  Instead, what is written to the tape is a
description, of sorts, of the sparse file: where the holes are, how
big the holes are, and how much data is found at the end of the hole.
This way, the file takes up potentially far less room on the tape,
and when the file is extracted later on, it will look exactly the way
it looked beforehand.  The following is a description of the fields
used to handle a sparse file:

The @code{sp} is an array of @code{struct sparse}.  Each @code{struct
sparse} contains two 12-character strings which represent an offset
into the file and a number of bytes to be written at that offset.
The offset is absolute, and not relative to the offset in preceding
array element.

The header can hold four of these @code{struct sparse} at the moment;
if more are needed, they are not stored in the header.

The @code{isextended} flag is set when an @code{extended_header}
is needed to deal with a file.  Note that this means that this flag
can only be set when dealing with a sparse file, and it is only set
in the event that the description of the file will not fit in the
alloted room for sparse structures in the header.  In other words,
an extended_header is needed.

The @code{extended_header} structure is used for sparse files which
need more sparse structures than can fit in the header.  The header can
fit 4 such structures; if more are needed, the flag @code{isextended}
gets set and the next record is an @code{extended_header}.

Each @code{extended_header} structure contains an array of 21
sparse structures, along with a similar @code{isextended} flag
that the header had.  There can be an indeterminate number of such
@code{extended_header}s to describe a sparse file.

@table @asis

@item @code{LF_NORMAL}
@itemx @code{LF_OLDNORMAL}
These flags represent a regular file.  In order to be compatible
with older versions of @code{tar}, a @code{typeflag} value of
@code{LF_OLDNORMAL} should be silently recognized as a regular file.
New archives should be created using @code{LF_NORMAL}.  Also, for
backward compatibility, @code{tar} treats a regular file whose name
ends with a slash as a directory.

@item @code{LF_LINK}
This flag represents a file linked to another file, of any type,
previously archived.  Such files are identified in Unix by each
file having the same device and inode number.  The linked-to name is
specified in the @code{linkname} field with a trailing null.

@item @code{LF_SYMLINK}
This represents a symbolic link to another file.  The linked-to name
is specified in the @code{linkname} field with a trailing null.

@item @code{LF_CHR}
@itemx @code{LF_BLK}
These represent character special files and block special files
respectively.  In this case the @code{devmajor} and @code{devminor}
fields will contain the major and minor device numbers respectively.
Operating systems may map the device specifications to their own
local specification, or may ignore the entry.

@item @code{LF_DIR}
This flag specifies a directory or sub-directory.  The directory
name in the @code{name} field should end with a slash.  On systems where
disk allocation is performed on a directory basis, the @code{size} field
will contain the maximum number of bytes (which may be rounded to
the nearest disk block allocation unit) which the directory may
hold.  A @code{size} field of zero indicates no such limiting.  Systems
which do not support limiting in this manner should ignore the
@code{size} field.

@item @code{LF_FIFO}
This specifies a FIFO special file.  Note that the archiving of a
FIFO file archives the existence of this file and not its contents.

@item @code{LF_CONTIG}
This specifies a contiguous file, which is the same as a normal
file except that, in operating systems which support it, all its
space is allocated contiguously on the disk.  Operating systems
which do not allow contiguous allocation should silently treat this
type as a normal file.

@item @code{A} @dots{} @code{Z}
These are reserved for custom implementations.  Some of these are
used in the GNU modified format, as described below.

@end table

Other values are reserved for specification in future revisions of
the P1003 standard, and should not be used by any @code{tar} program.

The @code{magic} field indicates that this archive was output in
the P1003 archive format.  If this field contains @code{TMAGIC},
the @code{uname} and @code{gname} fields will contain the ASCII
representation of the owner and group of the file respectively.
If found, the user and group IDs are used rather than the values in
the @code{uid} and @code{gid} fields.

@node Extensions, cpio, Standard, Archive Format
@section GNU Extensions to the Archive Format
@include docwarn.texi

The GNU format uses additional file types to describe new types of
files in an archive.  These are listed below.

@table @code

@item LF_DUMPDIR
@itemx 'D'
This represents a directory and a list of files created by the
@value{incremental} option.  The @code{size} field gives the total
size of the associated list of files.  Each file name is preceded by
either a @samp{Y} (the file should be in this archive) or an @samp{N}.
(The file is a directory, or is not stored in the archive.)  Each file
name is terminated by a null.  There is an additional null after the
last file name.

@item LF_MULTIVOL
@itemx 'M'
This represents a file continued from another volume of a multi-volume
archive created with the @value{multi-volume} option.  The original
type of the file is not given here.  The @code{size} field gives the
maximum size of this piece of the file (assuming the volume does
not end before the file is written out).  The @code{offset} field
gives the offset from the beginning of the file where this part of
the file begins.  Thus @code{size} plus @code{offset} should equal
the original size of the file.

@item LF_SPARSE
@itemx 'S'
This flag indicates that we are dealing with a sparse file.  Note
that archiving a sparse file requires special operations to find
holes in the file, which mark the positions of these holes, along
with the number of bytes of data to be found after the hole.

@item LF_VOLHDR
@itemx 'V'
This file type is used to mark the volume header that was given with
the @value{label} option when the archive was created.  The @code{name}
field contains the @code{name} given after the @value{label} option.
The @code{size} field is zero.  Only the first file in each volume
of an archive should have this type.

@end table

You may have trouble reading a GNU format archive on a non-GNU
system if the options @value{incremental}, @value{multi-volume},
@value{sparse}, or @value{label} were used when writing the archive.
In general, if @code{tar} does not use the GNU-added fields of the
header, other versions of @code{tar} should be able to read the
archive.  Otherwise, the @code{tar} program will give an error, the
most likely one being a checksum error.

@node cpio,  , Extensions, Archive Format
@section Comparison of @code{tar} and @code{cpio}
@include docwarn.texi

Here is a summary of differences between @code{tar} and @code{cpio}.
The accuracy of the following information has not been verified.
The following people contributed to this section, mainly through a
survey conducted in 1991.  The remainder of this section does not
otherwise try to relate topics to people.

@example
Bent Bertelsen          dmdata@@login.dkuug.dk
David Hoopes            talgras!david
Guy Harris              guy@@auspex.com
Kai Petzke              wpp@@marie.physik.tu-berlin.de
Kristen Nielsen         dmdata@@login.dkuug.dk
Leslie Mikesell         les@@chinet.chi.il.us
@end example

@format
FIXME: Reorganize the following material
@end format

@code{tar} handles symbolic links in the form in which it comes in BSD;
@code{cpio} doesn't handle symbolic links in the form in which it comes
in System V prior to SVR4, and some vendors may have added symlinks
to their system without enhancing @code{cpio} to know about them.
Others may have enhanced it in a way other than the way I did it
at Sun, and which was adopted by AT&T (and which is, I think, also
present in the @code{cpio} that Berkeley picked up from AT&T and put
into a later BSD release---I think I gave them my changes).

(SVR4 does some funny stuff with @code{tar}; basically, its @code{cpio}
can handle @code{tar} format input, and write it on output, and it
probably handles symbolic links.  They may not have bothered doing
anything to enhance @code{tar} as a result.)

@code{cpio} handles special files; traditional @code{tar} doesn't.

@code{tar} comes with V7, System III, System V, and BSD source;
@code{cpio} comes only with System III, System V, and later BSD
(4.3-tahoe and later).

@code{tar}'s way of handling multiple hard links to a file can handle
file systems that support 32-bit inumbers (e.g., the BSD file system);
@code{cpio}s way requires you to play some games (in its "binary"
format, i-numbers are only 16 bits, and in its "portable ASCII" format,
they're 18 bits---it would have to play games with the "file system ID"
field of the header to make sure that the file system ID/i-number pairs
of different files were always different), and I don't know which
@code{cpio}s, if any, play those games.  Those that don't might get
confused and think two files are the same file when they're not, and
make hard links between them.

@code{tar}s way of handling multiple hard links to a file places only
one copy of the link on the tape, but the name attached to that copy
is the @emph{only} one you can use to retrieve the file; @code{cpio}s
way puts one copy for every link, but you can retrieve it using any
of the names.

@quotation
>What type of check sum (if any) is used, and how is this calculated.
@end quotation

See the attached manual pages for @code{tar} and @code{cpio} format.
@code{tar} uses a checksum which is the sum of all the bytes in the
@code{tar} header for a file; @code{cpio} uses no checksum.

@quotation
>If anyone knows why @code{cpio} was made when @code{tar} was prasent
>at the unix scene,
@end quotation

It wasn't.  @code{cpio} first showed up in PWB/UNIX 1.0; no
generally-available version of UNIX had @code{tar} at the time.  I don't
know whether any version that was generally available @emph{within AT&T}
had @code{tar}, or, if so, whether the people within AT&T who did
@code{cpio} knew about it.

On restore, if there is a corruption on a tape @code{tar} will stop at
that point, while @code{cpio} will skip over it and try to restore the
rest of the files.

The main difference is just in the command syntax and header format.

@code{tar} is a little more tape-oriented in that everything is blocked
to start on a block boundary.
 
@quotation
>Is there any differences between the ability to recover crashed
>archives between the two of them. (Is there any chance of recovering
>crashed archives at all.)
@end quotation

Theoretically it should be easier under @code{tar} since the blocking
lets you find a header with some variation of @samp{dd skip=@var{nn}}.
However, modern @code{cpio}'s and variations have an option to just
search for the next file header after an error with a reasonable chance
of re-syncing.  However, lots of tape driver software won't allow you to
continue past a media error which should be the only reason for getting
out of sync unless a file changed sizes while you were writing the
archive.

@quotation
>If anyone knows why @code{cpio} was made when @code{tar} was prasent
>at the unix scene, please tell me about this too.
@end quotation

Probably because it is more media efficient (by not blocking everything
and using only the space needed for the headers where @code{tar}
always uses 512 bytes per file header) and it knows how to archive
special files.

You might want to look at the freely available alternatives.  The major
ones are @code{afio}, GNU @code{tar}, and @code{pax}, each of which
have their own extensions with some backwards compatibility.

Sparse files were @code{tar}red as sparse files (which you can easily
test, because the resulting archive gets smaller, and GNU @code{cpio}
can no longer read it).

@node Index,  , Archive Format, Top
@unnumbered Index

@printindex cp

@summarycontents
@contents
@bye

@c Local variables:
@c texinfo-column-for-description: 32
@c End:
