GNU tar 1.34: 4.2.4 Combining Archives with --concatenate
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.2.4 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
’, give the first archive with ‘--file
’ option and name the rest of archives to be concatenated on the command line. The members, and their member names, will be copied verbatim from those archives to the first one(11). The new, concatenated archive will be called by the same name as the one given with the ‘--file
’ option. As usual, if you omit ‘--file
’, tar
will use the value of the environment variable TAPE
, or, if this has not been set, the default archive 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 rock $ 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-r--r-- melissa/user 105 1997-01-21 19:42 blues -rw-r--r-- melissa/user 33 1997-01-20 15:34 rock $ tar -tvf jazzfolk.tar -rw-r--r-- melissa/user 20 1996-09-23 16:44 folk -rw-r--r-- 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 ‘bluesrock.tar’, you will see that now it also contains the archive members of ‘jazzfolk.tar’:
$ tar --list --file=bluesrock.tar blues rock folk jazz
When you use ‘--concatenate
’, the source and target archives must already exist and must have been created using compatible format parameters. Notice, that tar
does not check whether the archives it concatenates have compatible formats, it does not even check if the files are really tar archives.
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.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 24, 2021 using texi2html 5.0.