解决7z解压速度慢的问题

in zip •  6 years ago  (edited)

碰到一个问题,为了数据比较好拷贝,将大量(约200万个文件)的小文本文件用7z压缩,但是在解压的时候速度非常的慢,具体的原因也不太清楚,有可能是CPU的瓶颈问题,活着是硬盘的缓存问题。这个解压速度非常的慢,而且是随着解压的进程越来越慢,尝试使用pylzmapy7zlib编写脚本进行解压,速度还是非常的慢。最后发现一个速度比较快的法子,就是使用7z命令行的一个-so的开关,将数据输出到标准流,然后将标准流直接输出到文件,速度快了不少。最后需要读取一个大文件,它包含所有小文件内容,这里就需要根据文件内容的特点进行单个文件内容的匹配。所以这个方法比较适合大量结构类似的小文件,容易对单个文件内容进行提取。
标准输出流命令:
7z x filename.7z -so > outputfile

为了是文件名称和每一个文件的内容对应起来,需要将解压的信息流和内容标准输出流依次输出到文件中,命令如下:
7z x filename.7z -so > outputfile 2>&1
如果不指定标准输出-so的设备,也就是目标文件,7z会提示说不能将数据和程序信息输出到同一个终端(i won't write data and program's messages to same terminal),可以分别指定1>2>的设备,2>默认的是当前终端,1>就是指定的文件。这里为了将文件名称和文件内容对应,需要将程序信息输出重新定向到标准输出设备,即命令的后部分2>&1

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @verusloo! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - A better rich list comparator
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @verusloo! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

Click here to view your Board

Support SteemitBoard's project! Vote for its witness and get one more award!