Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在一个目录中,是否可以只压缩包含“foo”的文件?我可以找到它们, find . -name "*foo*"但我需要一种方法来存档它们。
find . -name "*foo*"
谢谢你。
我假设您的意思是归档到单个 tar 文件中?不是单独的 .gz 文件?试试这个:(假设没有太多文件)
find . -name "*foo*" | xargs tar cvzf archive.tar.gz
另一种方法是执行以下操作:
find . -name "*foo*" > list.txt tar cvzf archive.tar.gz -T list.txt #(works only with gnu tar, not bsd i think)