简体   繁体   English

通过SSH仅Gzip包含“ * foo *”的文件

[英]Gzip only files containing “*foo*” over SSH

In a directory, is it possible to gzip only files containing "foo"? 在目录中,是否可以仅gzip压缩包含“ foo”的文件? I can find them all by find . -name "*foo*" 我可以通过find . -name "*foo*"找到它们find . -name "*foo*" find . -name "*foo*" but i need a way to archive them. find . -name "*foo*"但我需要一种存档方式。

Thank you. 谢谢。

I assume you mean archive into a single tar file? 我假设您的意思是存档到单个tar文件中? Not individual .gz files? 不是单个的.gz文件? Try this: (assumes there aren't too many files) 尝试以下操作:(假设文件没有太多)

find . -name "*foo*" | xargs tar cvzf archive.tar.gz

An alternative is to do something like: 一种替代方法是执行以下操作:

find . -name "*foo*" > list.txt
tar cvzf archive.tar.gz -T list.txt #(works only with gnu tar, not bsd i think)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM