Linux 如何使用 tar 并提取除某些文件之外的所有内容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18124742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how use tar and extract everything except certain files?
提问by trafalgar
I want to extract website.tgz but I don't want these to "come out":
我想提取 website.tgz 但我不希望这些“出来”:
app/config.ini
log/
How do I do this?
我该怎么做呢?
Or/also how do I overwrite everything except the above?
或者/还有我如何覆盖除上述内容之外的所有内容?
采纳答案by Tarun
Try using the following command
尝试使用以下命令
tar -xvzf /path/to/tarfile --exclude='file dont want to extract'
回答by Basile Starynkevitch
You can use, as commented by Gryphius, the --exclude
option to GNU tar.
正如Gryphius所评论的,您可以使用GNU tar--exclude
选项。
You could also post-process the tar archive with tardy.
您还可以使用tardy对 tar 存档进行后处理。
tardy
enables you to do other useful transformations (e.g. prefixing the archived file paths, changing user or group name, etc...).
tardy
使您能够进行其他有用的转换(例如,为存档文件路径添加前缀、更改用户名或组名等...)。