Go to the previous, next section.

Concatenating Archives

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

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 cat, the utility for adding files together, for this purpose, archives created by tar incorporate an end of file marker which must be removed if the concatenated archives are to be read properly as one archive

FIXME: xref Ignore zeros.
To add archives to the end of another archive, therefore, you should use the `--concatenate' (`-A') operation.

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

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

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

To concatenate archive files, use the `--concatenate' (`-A') option. This operation adds other archives to the end of an archive. While it may seem intuitive to concatenate archives using cat, the utility for adding files together, archive files which have been "catted" together cannot be read properly by tar. Archive files incorporate an end of file marker--if archives are concatenated using cat, this marker will appear before the end of the new archive. This will interfere with operations on that archive.

FIXME: xref ignore-zeros

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

To store current versions of the files in `practice' in the archive file `music', you can use `--concatenate' (`-A') to add the archive file `~/practice/records' to `music'. First, make sure you are in your home directory (`cd ~'). Then:

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

If you now list the contents of the `music', you see it now contains the archive members of `practice/records':

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

Go to the previous, next section.