英文:
How to overwrite a file in a tarball
问题
我有一个特殊情况,两个文件具有相同的名称但内容不同,并且被写入同一个tar压缩包。这导致tar压缩包中存在两个条目。我想知道是否有办法让tar在压缩包中已存在同名文件时覆盖它,而不是创建另一个同名文件。
英文:
I've got an edge case where two files have the same name but different contents and are written to the same tarball. This causes there to be two entries in the tarball. I'm wondering if there's anything I can do to make the tar overwrite the file if it already exists in the tarball as opposed to creating another file with the same name.
答案1
得分: 0
第一个文件已经在你要求写第二个文件时被写入,并且流已经前进到了下一个位置,所以无法实现。请记住,tar文件是按顺序访问的。
在开始写入之前,你应该进行去重操作。
英文:
No way as the first file have already been written when you ask to write the second one and the stream has advanced the position. Remember tar files are sequentially accessed.
You should do deduplication before starting to write.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论