Command to find all view private files in the current directory recursively

帅比萌擦擦* 提交于 2019-12-27 17:39:49

问题


What is the clearcase Command to find all view private files in the current directory recursively?


回答1:


The usual commands are based on cleartool ls:

  • ct lsprivate: but it is only for dynamic views, not snapshot views
  • ct ls -rec -view_only: at least, it works in both snapshot and dynamic views

However both list also your checked-out files.

If you want only the private files, ie skipping the hijacked/eclipsed/checked-out and symlinks, you need to filter those out.

In Windows, that would be:

for /F "usebackq delims=" %i in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do @echo "%i"

In Unix:

cleartool ls -rec | grep -v "Rule:" | grep -v "hijacked" | grep -v "eclipsed" | grep -v "-->" | xargs echo



回答2:


In case it helps anyone else reading this question here is VonC's windows solution with a couple of minor changes to run as a windows script:

@echo off
setlocal
for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do @echo "%%A"

Replace @echo with rmdir /S /Q and del /F to do the actual deletions as described here. So the final script is:

@echo off
setlocal
for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do rmdir /S /Q "%%A"
for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->"`) do del /F "%%A"

If you save as a .bat file under the element of the view you are cleaning from, the script will clean up by deleting itself as well :-)




回答3:


I amended the version by @MilesHampson since this returned too many results for me and, I want to run this as a batch file.

My new files won't be in the debug or obj folder and as such, I don't need to see any results for those folders... I'm also only working on C#. So that's all I need to see.

@echo off
setlocal

@echo Searching, please wait as this can take a while...

for /F "usebackq delims=" %%A in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->" ^| find /V "obj" ^| find /V "debug"`) do  ( 
  if "%%~xA"==".cs" echo %%A
  )
)

@echo === === === === === Search Complete === === === === === === 

pause

Create a bat file with the above, drop it into your root project folder and run it. It will display those not in source control.




回答4:


In case it helps anyone else reading this question, here is VonC's Unix solution with a couple of minor changes to run under Cygwin on Windows.

In Cygwin:

cleartool ls -rec | grep -v "Rule:" | grep -v "hijacked" | grep -v "eclipsed" | grep -v -- "-->" 

The Cygwin line is similar to the Unix given by VonC, but note the double-dash on the last grep is needed (and the xargs is not needed).




回答5:


ct lsprivate -other 

Would also filter out checked-out files

ct lsprivate -co : list all checked-out files

ct lsprivate -do : list all derived object files

ct lsprivate -other : list all other private files




回答6:


I followed all above solutions and it is great command. I had some more requirements that were not covered above so I modified script little more with below additional points

  1. Excluded batch file from list (otherwise current batch file also coming in list)
  2. Removed Directory from list as generally I am interested in file

  3. Specially for java developer, excluded target folder and jar files as they are not generally checked in

  4. Removed .classpath, .project and .settings folder which is specific to Eclipse (if they are same level as project/modules)

    @echo off
    setlocal
    
    @echo.
    @echo Searching, please wait as this can take a while...
    @echo.
    for /F "usebackq delims=" %%i in (`cleartool ls  -rec ^| find /V "Rule:" ^| find /V "hijacked" ^| find /V "eclipsed" ^| find /V "-->" ^| find /V ".settings" ^| find /V "jar" ^| find /V "keep" ^| find /V "target" ^| find /V ".classpath"  ^| find /V ".project" ^| find /V "%~n0" `) do ( if not exist %%i\* @echo "%%i")
    
    @echo.
    @echo === === === === === Search Complete === === === === === === 
    @echo.
    @echo.
    
    pause
    


来源:https://stackoverflow.com/questions/7657084/command-to-find-all-view-private-files-in-the-current-directory-recursively

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!