(tar)Append bis


Next: Update bis Prev: How to Add Files to Existing Archives Up: How to Add Files to Existing Archives

Appending Files to an Archive
-----------------------------

     *(This message will disappear, once this node revised.)*

   The simplest method of adding a file to an already existing archive
is the `--append' (`-r') 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 `--append' (`-r') 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 `rock' in the
practice directory which did not exist in either the archive file
`records', in the practice directory, or the archive file `music', in
the home directory.  To add `rock' to `records', you would, while in
the practice directory:

   * Invoke `tar' and specify the operation to add a file--`--append'
     (`-r').

   * Specify the name of the archive to which the file will be
     added--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').

   * Specify the name(s) of the file(s) to be added to the archive as
     the file name argument(s)

     % tar --append --file=records rock

If you now use the `--list' (`-t') operation, you will see that `rock'
has been added to the archive:

     % tar --list --file=records
     blues
     folk
     jazz
     rock

   While all newly created files have now been added to `records', it
is still not current with respect to the contents of the practice
directory.  If you recall from the examples using `--compare' (`-d')
above, `blues' was changed after the archive `records' was created.  It
is simple, however, to use `--append' (`-r') to correct the problem:

     % tar --append --verbose --file=records blues
     blues

Because you specified the `--verbose' (`-v') option, `tar' has printed
the name of the file being appended as it was acted on.  If you now use
`tar' with the `--list' (`-t') option specified to get the contents of
the archive, you will optain the following:

     % tar --list -f records
     blues
     folk
     jazz
     rock
     blues

The newest version of `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 `records' are extracted the newer version of `blues'
(which has the same name as the older) will overwrite the version
stored first.
FIXME: xref Keep Old Files

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

   The simplest method of adding a file to an existing archive is the
`--append' (`-r') operation, which writes files into the archive
without regard to whether or not they are already archive members.
When you use `--append' (`-r') you must use file name arguments; there
is no default.  If you specify a file that is already stored in the
archive, `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 `~/practice/rock' which has not been stored in either
the archive file `~/practice/records', or the archive file `~/music'.
To add `rock' to `records', first make `practice' the working directory
(`cd practice').  Then:

   * Invoke `tar' and specify the `--append' (`-r') operation.

   * Specify the archive to which the file will be
     added--`--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME').

   * Specify the files to be added to the archive, using file name
     arguments

   For example:

     % tar --append --file=records rock

   If you list the archive members in `records', you will see that
`rock' has been added to the archive:

     % tar --list --file=records
     blues
     folk
     jazz
     rock

FIXME: this should be some kind of node.

   You can use `--append' (`-r') to keep archive members current with
active files.  Because `--append' (`-r') stores a file whether or not
there is already an archive member with the same file name, you can use
`--append' (`-r') 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 `--extract' (`-x') 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 `--compare' (`-d') above,
`blues' was changed after the archive `records' was created. It is
simple, however, to use `--append' (`-r') to add the new version of
`blues' to `records':

     % tar --append --verbose --file=records blues
     blues

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

     % tar --list -f records
     blues
     folk
     jazz
     rock
     blues

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


automatically generated by info2www version 1.2