ClearCase - How to Find All Checkins By One User for an Entire PVOB? - find

I have been asked to find every checkin by one specific user across an entire ClearCase Project VOB since a particular date. How might I obtain this information?
I assume it's some usage of the cleartool find command, but I've not yet figured out the syntax to get the information that I'm looking for.
I guess I'm looking for a "change set" across every activity of that user across every stream of a given PVOB since a particular date.

Looking at cleartool find (which work for versions created with or without UCM), it should be something like:
cleartool find . -user <auser> -version "{created_since(date1)}" -print
This is done within a vob, not a pvob, as it search for version (data), not UCM activities (metadata recorded on PVob level)
You need first to go to a view, preferably a dynamic view:
cd m:\aView\aVob
# unix
cd /view/aview/vobs/avob
As noted by the OP's answer, what works is:
using create_by instead of -user,
adding -all -nvis.

With the repeated help of (and huge thanks to) #VonC, here is what I wound up using, at a command prompt (not in a ClearTool session), with my working directory set to the directory just beneath the root of my snapshot view:
cleartool find . -all -name "*" -version "{created_by(<userid>) && created_since(dd-Mmm-yyyy)}" -print > <absolute path to output file>
Update: The command below, which was originally my answer, returns only invisible files:
cleartool find . -all -nvisible -name "*" -version "{created_by(<userid>) && created_since(dd-Mmm-yyyy)}" -print > <absolute path to output file>

Related

Command line find if path matches and remove all contents

I'm trying to locate all folders that match a certain path.
The path is public_html/core/cache
I can find all instances of cache with the command below, however this does return results from elsewhere which are undesired!
find . -name cache -print
I've tried the below, but it presents an error.
find . -name public_html/core/cache -print
I'd like to run the script once to ensure the results are accurate, then afterwards run it again, removing all contents of the returned folder.
Many thanks in advance
A kind friend gave me the solution:
find / -type d -path "*core/cache" -print

cleartool find difference recursive in certain file type to predecessor

In my script I'm calling ClearCase to check if any file of a certain file type in the current path (including all subfolders) has been changed. I'm not familiar with cleartool at all, the command should like this:
cleartool diff -predecessor -recursive *.filetype
As a return value I only need a bool: true if any differences exist, false if nothing has changed
As a return value I only need a bool: true if any differences exist, false if nothing has changed
You need a script. A simple find + exec won't be enough, because the exit status won't be exactly what you need.
#! /bin/bash
noChange=0 ### "cleartool diff" exit status means no difference
files=$(cleartool find . -name "*.filetype")
for f in ${file}; do;
cleartool diff -pre -options "-status_only" "${f}"
if [ $? != $noChange ]; then
exit 0
fi
done
exit 1
(0 is true, false is 1 in shell)
Note the use, in cleartool diff of the -options parameter:
opt/ions pass-through-opts
Specifies one or more compare method options that are not directly supported by diff.
That way, you get only the status from cleartool diff, which is precisely what you want to test in your case.
Since your previous question shows you have Git too, you can easily execute that script in a bash session, even on Windows.
On first glance, the command you're looking for is something like this:
cleartool find . -name "*.filetype" -exec 'cleartool diff -pred "$CLEARCASE_PN"'
On windows, it would look like this:
cleartool find . -name "*.filetype" -exec "cleartool diff -pred \"%CLEARCASE_PN%\""
The single quotes in the Unix example are significant since otherwise the "CLEARCASE_PN" environment variable reference would be expanded at the time you start the command and not when the -exec is actually fired.
The \"%CLEARCASE_PN%\" construct in the Windows command line and the "$CLEARCASE_PN" on unix is to account for filenames including spaces.
Now, looking at what you want... I'm not sure it would accomplish the underlying purpose, whatever that is.

Querying multiple versions of same file in Clearcase

I would like to write a little batch script, which I would use to collect all of the comments of a file on a specific branch. For example, if I have an ABC.cpp file under the myBranch branch and it has already 3 versions, I would like to have the comments from version 1, 2 and 3.
I still couldn't get multiple versions of the same file. I am using the "find" command of cleartool. Maybe it is not possible in a simple cleartool find command, so let me know, if that's so.
Thanks!
If is possible to list the version of a file, either with cleartool find (using the -ver), or with cleartool lshist.
For a specific branch:
cleartool find . -name "ABC.cpp" -ver "{brtype(myBranch)}"
For each file, you can access its content with cleartool get.
See also "In ClearCase, how can I view old version of a file in a static view, from the command line?"
cleartool find . -name "ABC.cpp" -ver "{brtype(myBranch)}" -exec

Wild cards search in eclipse

The project in our company includes a variety of files. Many a times, it becomes necessary to search all but a few file types. Is there a way to exclude some extensions while doing a searching *.* file search.
One way I know of is to do it via resource filters, but then those exclusions become permanent. What I want is to search for *.*, while removing say *.jsp or *.sql or *.cpp files on the fly.
Thanks,
Ron
You do not mention how you are performing the searches. Personally, I am quite comfortable with the Unix command line, so I have found that having a couple of terminals open on the directory of my Eclipse workspace always comes handy.
On the shell command line, using find and sort to show all files under the current directory:
$ find -type f | sort
./a/a0.txt
./a/a1.doc
./b/b0.rtf
./b/b1.cpp
./b/b2.jsp
./c/c0.jsp
./c/c1.sql
./c/c2.cpp
To show all files except for those matching *.cpp:
$ find -type f ! -name '*.cpp' | sort
./a/a0.txt
./a/a1.doc
./b/b0.rtf
./b/b2.jsp
./c/c0.jsp
./c/c1.sql
To show all files except for those matching *.cpp or *.jsp:
$ find -type f ! -name '*.cpp' ! -name '*.jsp' | sort
./a/a0.txt
./a/a1.doc
./b/b0.rtf
./c/c1.sql
To show all files matching ?1.* except for those matching *.sql:
$ find -type f -name '?1.*' ! -name '*.sql' | sort
./a/a1.doc
./b/b1.cpp
find is the standard Unix command line utility for file searching. Unfortunately, while some of its options are standardized, others are different among the various Unix-like operating systems. You should probably have a look at its manual page (man find) to find out the options that your version of find accepts. The manual page I linked to is for GNU find, which is what most (all?) Linux distributions come with.
If you use Eclipse itself to perform the searches, you can do the following:
Click on Search in the menu bar
Select File
A File Search dialog will pop-up
Click on the Choose button next to the File name patterns textbox
Click on Select all - then remove the check-mark from those extensions you wish to exclude, making sure to exclude *.* as well
A pattern list will appear in the File name patterns textbox
Click Search and a new view with the search results will appear
Disclaimer: this is on Eclipse 3.7.1
This method does not seem to be as powerful as using find, but it offers better integration with Eclipse.

using grep and find commands - basic questions to help me sort it out in my simple mind

I am back with a second no-brainer question, but I would like to get this straight in my head.
I have an assignment in which I am charged with providing a command to find a file named test in my home directory (one command using find, and one using grep). I understand that using find is just 'find ~/test', but using grep, wouldn't I have to search out a pattern within the file 'test'? Or is there a way to search for the file (using grep), even if the file is empty?
ls ~ | grep test
I understand that using find is just 'find ~/test'
No. find ~/test will also have a match for every file or directory under the directory $HOME/test/. Rather use find ~ -type f -name test.
The assignment sounds unclear. But yes, if you give any filenames to grep, it will look at the contents of the files and ignore the names of the files. Perhaps you can grep the output of another command? Maybe ls as #Reese suggested, or maybe a different find command.
ls -R ~ | grep test
Explanation: ls -R ~ will recursively list all files and directories in your home folder. grep test will narrow down that list to files (and directories) that have "test" in their name.