问题描述
我想在ClearCase中查找带有特定标签但没有设置其他标签的文件.
I'd like to find files in ClearCase that are labeled with a specific label but that do not have any other labels set.
例如,如果我有这样标记的文件:
For example, if I have files labeled like this:
file1 LBL_A, LBL_B
file2 LBL_A
我想查询一个仅提供file2而不是file1的查询.
I'd like to have a query that gives me just file2 and not file1.
有没有办法使用cleartool查找?如果使用单个查询无法做到这一点,那么我将对如何分几个步骤进行操作的任何想法感到高兴(我将从perl脚本中调用cleartool,因此可以很容易地保存文件列表并在其上运行进一步的命令.
Is there a way to do this with cleartool find? If this is not possible to do with a single query, I'd also be happy for any ideas how to do this in several steps (I'll be calling cleartool from a perl script, so it will be easy to save lists of files temporarily and run further commands on them).
非常感谢!
Jan
推荐答案
假定LBL_A是您要运行的(唯一)标签
Assuming LBL_A is the (only) label you want running
cleartool find /some/dir -version 'lbtype(LBL_A)' -print | xargs cleartool describe -fmt "%n: %l"
应该给予
file1: (LBL_A, LBL_B)
file2: (LBL_A)
作为输出,然后您可以在perl脚本中检入或通过sed -n 's/\(.*\): (LBL_A)/\1/p'
进行过滤(假设文件名中没有冒号).
as output which you then can check in your perl script or filter through sed -n 's/\(.*\): (LBL_A)/\1/p'
(assuming no colons in filenames).
更新:正如VonC正确指出的那样,上面的命令对于包含空格的文件将失败.要以以下方式运行该文件:
Update: As VonC correctly points out, the command above will fail for files with spaces in. To handle that run as:
cleartool find ... -print | tr '\012' '\000' | xargs -0 cleartool ....
这会将换行符转换为ascii null,然后让xargs将其用作分隔符.
which will translate newlines into ascii null and then have xargs use that as delimiter.
这篇关于ClearCase:查找仅具有一个特定标签而没有更多标签的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!