如何从tar.gz存档中删除单个文件 [英] How do I delete a single file from a tar.gz archive
问题描述
我有一个大型的tarbell存档,其中的error_log过大或损坏,导致尝试提取存档时挂起.有没有一种方法可以在解压缩之前解压缩此文件,或者在不解压缩Mac OS X终端上特定文件的情况下解压缩该文件?
I have a huge tarbell archive with an excessively large or corrupt error_log that causes the archive to hang when attempting to extract it. Is there a way to remove this from the archive before unzipping or extract the archive without extracting that specific file on Mac OS X terminal?
我找到了有关如何 efficiency-remove-files-from-的信息large-tgz 但是,我尝试了--delete标志,但是收到了此错误:
I found this post on how to efficiently-remove-files-from-large-tgz however, I tried the --delete flag, but received this error:
tar: Option --delete is not supported
有没有办法:
- 从存档中删除文件而不解压缩吗?
- 提取存档但排除文件?
推荐答案
如注释中所述,无法使用tar删除文件,但是在提取时可以排除文件:
As mentioned in the comments it's not possible to remove the file using tar, but you can exclude the file when extracting:
tar -zxvf file.tar.gz --exclude "file_to_exclude"
这篇关于如何从tar.gz存档中删除单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!