linux – 有没有快速的方法来获取大型TAR中的最后一个文件?

前端之家收集整理的这篇文章主要介绍了linux – 有没有快速的方法来获取大型TAR中的最后一个文件?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
让我们假设我有一个几千兆字节的tar文件,但我也碰巧知道写入存档的最后一个文件是我需要的重要内容.由于tar文件是按顺序附加的,有没有一种方法可以让tar从末尾读入存档以查找此文件,而不是从头开始读取数十亿字节的无关数据?

解决方法

不,不幸的是没有.从 Wikipedia

Another weakness of the tar format compared to other archive formats is that there is no centralized location for the information about the contents of the file (a “table of contents” of sorts). So to list the names of the files that are in the archive,one must read through the entire archive and look for places where files start. Also,to extract one small file from the archive,instead of being able to lookup the offset in a table and go directly to that location,like other archive formats,with tar,one has to read through the entire archive,looking for the place where the desired file starts. For large tar archives,this causes a big performance penalty,making tar archives unsuitable for situations that often require random access of individual files.

原文链接:/linux/397209.html

猜你在找的Linux相关文章