tar: concatenate
1
1 4.2.4 Combining Archives with '--concatenate'
1 ---------------------------------------------
1
1 Sometimes it may be convenient to add a second archive onto the end of
1 an archive rather than adding individual files to the archive. To add
1 one or more archives to the end of another archive, you should use the
1 '--concatenate' ('--catenate', '-A') operation.
1
1 To use '--concatenate', give the first archive with '--file' option
1 and name the rest of archives to be concatenated on the command line.
1 The members, and their member names, will be copied verbatim from those
1 archives to the first one(1). The new, concatenated archive will be
1 called by the same name as the one given with the '--file' option. As
1 usual, if you omit '--file', 'tar' will use the value of the environment
1 variable 'TAPE', or, if this has not been set, the default archive name.
1
1 To demonstrate how '--concatenate' works, create two small archives
1 called 'bluesrock.tar' and 'folkjazz.tar', using the relevant files from
1 'practice':
1
1 $ tar -cvf bluesrock.tar blues rock
1 blues
1 rock
1 $ tar -cvf folkjazz.tar folk jazz
1 folk
1 jazz
1
1 If you like, You can run 'tar --list' to make sure the archives contain
1 what they are supposed to:
1
1 $ tar -tvf bluesrock.tar
1 -rw-r--r-- melissa/user 105 1997-01-21 19:42 blues
1 -rw-r--r-- melissa/user 33 1997-01-20 15:34 rock
1 $ tar -tvf jazzfolk.tar
1 -rw-r--r-- melissa/user 20 1996-09-23 16:44 folk
1 -rw-r--r-- melissa/user 65 1997-01-30 14:15 jazz
1
1 We can concatenate these two archives with 'tar':
1
1 $ cd ..
1 $ tar --concatenate --file=bluesrock.tar jazzfolk.tar
1
1 If you now list the contents of the 'bluesrock.tar', you will see
1 that now it also contains the archive members of 'jazzfolk.tar':
1
1 $ tar --list --file=bluesrock.tar
1 blues
1 rock
1 folk
1 jazz
1
1 When you use '--concatenate', the source and target archives must
1 already exist and must have been created using compatible format
1 parameters. Notice, that 'tar' does not check whether the archives it
1 concatenates have compatible formats, it does not even check if the
1 files are really tar archives.
1
1 Like '--append' ('-r'), this operation cannot be performed on some
1 tape drives, due to deficiencies in the formats those tape drives use.
1
1 It may seem more intuitive to you to want or try to use 'cat' to
1 concatenate two archives instead of using the '--concatenate' operation;
1 after all, 'cat' is the utility for combining files.
1
1 However, 'tar' archives incorporate an end-of-file marker which must
1 be removed if the concatenated archives are to be read properly as one
1 archive. '--concatenate' removes the end-of-archive marker from the
1 target archive before each new archive is appended. If you use 'cat' to
1 combine the archives, the result will not be a valid 'tar' format
1 archive. If you need to retrieve files from an archive that was added
1 to using the 'cat' utility, use the '--ignore-zeros' ('-i') option.
1 ⇒Ignore Zeros, for further information on dealing with archives
1 improperly combined using the 'cat' shell utility.
1
1 ---------- Footnotes ----------
1
1 (1) This can cause multiple members to have the same name. For
11 information on how this affects reading the archive, see ⇒
multiple.
1