views:

1271

answers:

2

Using the ClearCase find command, how do I find all files in a directory that do not have the name pom.xml?

I'd like to pass other selection options to the ClearCase find command so I'd prefer not to execute another command.

I am using a RedHat linux version of ClearCase. I have tried "cleartool find ! -name pom.xml -print" and that does not work.

PS: I do not use ClearCase by choice, it's mandated on my project. This is one of the reasons I hate it. I've read the man pages several times and see no clear way to do this that works!

+2  A: 

ClearCase wildcards doesn't have inversion (AFAIR) but you can use grep for this -

cleartool ls -short -nxname | grep -v pom.xml
Dmitry Khalatov
I don't think that was the xml name the OP was using ;-)
Tanktalus
+1  A: 

You seem to forget the -exec option of the cleartool find command.

It actually does allow you to execute other commands than cleartool ones, including system ones (like a sh or DOS script).

I know you would "prefer not to execute another command", but if that other system script is part of the exec option of a find command... it can be argued it is still one command ;)

So create a simple script like:

(Unix 'print.sh')

#!/bin/sh
if [ $1 != $2 ] ; then
  echo $1
fi

(windows 'print.bat')

@echo off
if not "%1"=="%2" echo "%1"

Put that script either in your search directory, or add the script path to your %PATH% or $PATH environment.

And finally, use the find command (with all the other options regarding date filtering, branch filtering and so on)

(Unix)

cleartool find . -nrec -type f -exec './print.sh $CLEARCASE_PN ./pom.xml'

(windows)

cleartool find . -nrec -type f -exec "print.bat %CLEARCASE_PN% .\pom.xml"

And here you go: "all files in a directory that do not have the name pom.xml".

Note: the '-type f' option of the find command allows you to restrict the search to file names only (not directory names).

VonC