Go to the first, previous, next, last section, table of contents.


Multiple Files with the Same Name

You can use --append (-r) to add copies of files which have been updated since the archive was created. (However, we do not recommend doing this since there is another tar option called `--update'; see section Updating an Archive for more information. We describe this use of `--append' here for the sake of completeness.) @FIXME{is this really a good idea, to give this whole description for something which i believe is basically a Stupid way of doing something? certain aspects of it show ways in which tar is more broken than i'd personally like to admit to, specifically the last sentence. On the other hand, i don't think it's a good idea to be saying that re explicitly don't recommend using something, but i can't see any better way to deal with the situation.} When you extract the archive, the older version will be effectively lost. This works because files are extracted from an archive in the order in which they were archived. Thus, when the archive is extracted, a file archived later in time will overwrite a file of the same name which was archived earlier, even though the older version of the file will remain in the archive unless you delete all versions of the file.

Supposing you change the file `blues' and then append the changed version to `collection.tar'. As you saw above, the original `blues' is in the archive `collection.tar'. If you change the file and append the new version of the file to the archive, there will be two copies in the archive. When you extract the archive, the older version of the file will be extracted first, and then overwritten by the newer version when it is extracted.

You can append the new, changed copy of the file `blues' to the archive in this way:

$ tar --append --verbose --file=collection.tar blues
blues

Because you specified the `--verbose' option, tar has printed the name of the file being appended as it was acted on. Now list the contents of the archive:

$ tar --list --verbose --file=collection.tar
-rw-rw-rw- me user     28 1996-10-18 16:31 jazz
-rw-rw-rw- me user     21 1996-09-23 16:44 blues
-rw-rw-rw- me user     20 1996-09-23 16:44 folk
-rw-rw-rw- me user     20 1996-09-23 16:44 rock
-rw-rw-rw- me user     58 1996-10-24 18:30 blues

The newest version of `blues' is now at the end of the archive (note the different creation dates and file sizes). If you extract the archive, the older version of the file `blues' will be overwritten by the newer version. You can confirm this by extracting the archive and running `ls' on the directory. See section Changing How tar Writes Files for more information. (Please note: This is the case unless you employ the --backup option; @FIXME-ref{Multiple Members with the Same Name}.)


Go to the first, previous, next, last section, table of contents.