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


Combining Archives with --concatenate

Sometimes it may be convenient to add a second archive onto the end of an archive rather than adding individual files to the archive. To add one or more archives to the end of another archive, you should use the --concatenate (--catenate, -A) operation.

To use `--concatenate', name the archives to be concatenated 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 any members; all the members with the same name coexist. For information on how this affects reading the archive, @FIXME-ref{Multiple Members with the Same Name}.

To demonstrate how `--concatenate' works, create two small archives called `bluesrock.tar' and `folkjazz.tar', using the relevant files from `practice':

$ tar -cvf bluesrock.tar blues rock
blues
classical
$ tar -cvf folkjazz.tar folk jazz
folk
jazz

If you like, You can run `tar --list' to make sure the archives contain what they are supposed to:

$ tar -tvf bluesrock.tar
-rw-rw-rw- melissa user    105 1997-01-21 19:42 blues
-rw-rw-rw- melissa user     33 1997-01-20 15:34 rock
$ tar -tvf folkjazz.tar
-rw-rw-rw- melissa user     20 1996-09-23 16:44 folk
-rw-rw-rw- melissa user     65 1997-01-30 14:15 jazz

We can concatenate these two archives with tar:

$ cd ..
$ tar --concatenate --file=bluesrock.tar jazzfolk.tar

If you now list the contents of the `bluesclass.tar', you will see that now it also contains the archive members of `jazzfolk.tar':

$ tar --list --file=bluesrock.tar
blues
rock
jazz
folk

When you use `--concatenate', the source and target archives must already exist and must have been created using compatable format parameters (@FIXME-pxref{Matching Format Parameters}). The new, concatenated archive will be called by the same name as the first archive listed on the command line. @FIXME{is there a way to specify a new name?}

Like --append (-r), this operation cannot be performed on some tape drives, due to deficiencies in the formats those tape drives use.

It may seem more intuitive to you to want or try to use cat to concatenate two archives instead of using the `--concatenate' operation; after all, cat is the utility for combining files.

However, tar archives incorporate an end-of-file marker which must be removed if the concatenated archives are to be read properly as one archive. `--concatenate' removes the end-of-archive marker from the target archive before each new archive is appended. If you use cat to combine the archives, the result will not be a valid tar format archive. If you need to retrieve files from an archive that was added to using the cat utility, use the --ignore-zeros (-i) option. See section Ignoring Blocks of Zeros for further information on dealing with archives improperly combined using the cat shell utility.

@FIXME{this shouldn't go here. where should it go?} You must specify the source archives using --file=archive-name (-f archive-name) (see section Choosing and Naming Archive Files). If you do not specify the target archive, tar uses the value of the environment variable TAPE, or, if this has not been set, the default archive name.


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