Does it take a longer time to delete files from a large tar zip and rar archive than a smaller one? I would think that for a file to be deleted from an archive, all the data that exists after the deleted file would have to be re-written to the archive, thus taking longer as opposed to a smaller archive where the amount of data to re-write is less... if not, how are these archives able to remove data from the middle of the archive without re-writing the rest of the data?
You're exactly right. It depends a bit on the precise archive format and compression used, but generally, at a minimum, all the data stored "after" the deleted file must be rewritten.
@Doktoro Reichard, but simply "telling" the archive that the file no longer exists cannot possibly be enough as the data is still occupied inside the archive, and still takes up space. It would be like removing a section of wood in the middle of a tree. Therefore, the data that is present after the deleted file(s) must be re-written to the archive, overwriting the files that one would wish to delete, then, because the data has moved backwards in the archive so to speak, the archive must be truncated to archivesize-filesize at the end to remove the dead space... Only now can the index table be updated with the new position of each file after the deleted file.
Following this logic, the only thing that would effect the amount of data that needs to be re-written is the byte position or where the file is located inside the archive. A file at the end of the archive could simply be truncated away rather quickly..
This however raises another question from the top of my head... How are file systems able to do exactly this, remove a file from the middle without re-writing data? Take for example a dynamic virtual disk.
tar does not support compressed archive file modification. then you must completly rewrite tar archive, temporarly keep uncompressed one. it depends to tar archive format.
With regards to @David (the previous poster), I feel that the answer given is somewhat lacking.
Let's analyze the questions:
1. Does it take a longer time to delete files from a large tar zip and rar archive than a smaller one?
Yes it does, because the archive is bigger. However this is an absurd generalization. Considering the two main factors that may affect this: archive size and number of files archived.
If there is only one file archived, essentially what you're doing is deleting the archive itself. If there are many files, however, the archiving programs (and formats) have different ways to treat files.
Tar, for instance, was meant to be a sequential file storing format for storing tape archives. One of the disadvantages is that, since there is no "table of contents", it needs to iterate through the whole archive to find a folder or a file.
Rar, on the other hand, has an option to make solid files. A solid file is an archive where all information was previously treated as a big stream. This means that, whenever someone wants to access, edit, add or delete a file, the entire archive must first be decompressed, and then recompressed.
And now we come at something new: compression ratio. If the files are highly compressed, it will take more time, no matter the algorithm, to access them. Although this is dependent on the kind of files being compressed (text files (not .docx) have high redundancy so they can be de/recompressed quickly)
2. How are these archives able to remove data from the middle of the archive without re-writing the rest of the data?
The reasoning before this question isn't always valid, except for the rar "solid" archive.
Barring Tar (for reasons shown on the Wikipedia link), both zip and rar have something of a "table of contents" that enables the archives to selectively extract data. All this is done without recompressing the existing data, although some things need to be altered inside the archive to tell him that the file no longer exists.
Think of an archive as a small box, where each file is crammed and squeezed in order to fit it. As soon as you take one item, the box srinks in order to fill the space.