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

前端 未结 6 1293
情歌与酒
情歌与酒 2020-11-28 11:49

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

相关标签:
6条回答
  • 2020-11-28 12:15

    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
    
    0 讨论(0)
  • 2020-11-28 12:19

    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.

    0 讨论(0)
  • 2020-11-28 12:19

    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
      
    0 讨论(0)
  • 2020-11-28 12:29
    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

    0 讨论(0)
  • 2020-11-28 12:33

    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).

    0 讨论(0)
  • 2020-11-28 12:38

    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 :-)

    0 讨论(0)
提交回复
热议问题