tar: append
1
1 4.2.2 How to Add Files to Existing Archives: '--append'
1 -------------------------------------------------------
1
1 If you want to add files to an existing archive, you don't need to
1 create a new archive; you can use '--append' ('-r'). The archive must
1 already exist in order to use '--append'. (A related operation is the
1 '--update' operation; you can use this to add newer versions of archive
1 members to an existing archive. To learn how to do this with
1 '--update', ⇒update.)
1
1 If you use '--append' to add a file that has the same name as an
1 archive member to an archive containing that archive member, then the
1 old member is not deleted. What does happen, however, is somewhat
1 complex. 'tar' _allows_ you to have infinite number of files with the
1 same name. Some operations treat these same-named members no
1 differently than any other set of archive members: for example, if you
1 view an archive with '--list' ('-t'), you will see all of those members
1 listed, with their data modification times, owners, etc.
1
1 Other operations don't deal with these members as perfectly as you
1 might prefer; if you were to use '--extract' to extract the archive,
1 only the most recently added copy of a member with the same name as
1 other members would end up in the working directory. This is because
1 '--extract' extracts an archive in the order the members appeared in the
1 archive; the most recently archived members will be extracted last.
1 Additionally, an extracted member will _replace_ a file of the same name
1 which existed in the directory already, and 'tar' will not prompt you
1 about this(1). Thus, only the most recently archived member will end up
1 being extracted, as it will replace the one extracted before it, and so
1 on.
1
1 There exists a special option that allows you to get around this
1 behavior and extract (or list) only a particular copy of the file. This
1 is '--occurrence' option. If you run 'tar' with this option, it will
1 extract only the first copy of the file. You may also give this option
1 an argument specifying the number of copy to be extracted. Thus, for
1 example if the archive 'archive.tar' contained three copies of file
1 'myfile', then the command
1
1 tar --extract --file archive.tar --occurrence=2 myfile
1
1 would extract only the second copy. ⇒--occurrence Option Summary,
1 for the description of '--occurrence' option.
1
1 If you want to replace an archive member, use '--delete' to delete
1 the member you want to remove from the archive, and then use '--append'
1 to add the member you want to be in the archive. Note that you can not
1 change the order of the archive; the most recently added member will
1 still appear last. In this sense, you cannot truly "replace" one member
1 with another. (Replacing one member with another will not work on
DONTPRINTYET 1 certain types of media, such as tapes; see ⇒delete and *note1DONTPRINTYET 1 certain types of media, such as tapes; see ⇒delete and ⇒
Media, for more information.)
1
Menu