创建 tarball 时排除公共子目录 [英] Exclude common subdirectories when creating a tarball
问题描述
我正在创建一个在 ClearCase 中管理的大型代码库的 tarball.每个目录都有一个名为.CC"的子目录.我想从我的 tarball 中排除这些.
I'm creating a tarball of a large codebase managed in ClearCase. Every directory has a sub-directory named ".CC". I'd like to exclude these from my tarball.
我发现 在创建 .tar.gz 时排除目录文件,但排除它似乎需要在命令行上传递每个 .CC 目录.这对我来说是不切实际的.
I've found Excluding directory when creating a .tar.gz file, but excluding that would appear to require passing each and every .CC directory on the commndline. This is impractical in my case.
有没有办法排除符合特定模式的目录?
Is there a way to exclude directories that meet a particular pattern?
我不是在问如何排除特定的有限目录列表.我在问如何排除以特定模式结尾的所有目录.
I am not asking how to exclude a specific finite list of directories. I am asking how to exclude all directories that end in a particular pattern.
推荐答案
代替手动输入 --exclude 'root/a/.CC' --exclude 'root/b/.CC' ...
你可以输入 $(find root -type d -name .CC -exec echo "--exclude \'{}\'" \;|xargs)
Instead of manually typing --exclude 'root/a/.CC' --exclude 'root/b/.CC' ...
you can type $(find root -type d -name .CC -exec echo "--exclude \'{}\'" \;|xargs)
您可以使用 find
支持的任何模式,甚至可以在 find
和 xargs
之间使用类似 grep 之类的东西.
You can use whatever patterns find
supports, or even use something like grep inbetween find
and xargs
.
这篇关于创建 tarball 时排除公共子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!