On Unix (dynamic views), one very effective technique for removing view private files is to drop the view. Preserve the cspec first. Also make sure there are no checkouts in the view. Then remove it and recreate a new one (same name, same cspec, same storage, but no private files until you create them).
# With the view to be cleaned as your current view...
ct pwv -s > /tmp/viewname
viewname=$(</tmp/viewname)
ct catcs > /tmp/$viewname.cs
ct lsview -cvi | awk '{print $3;}' > /tmp/$viewname.vws
# The next line is the first dangerous line!
# It cancels all outstanding checkouts and removes the modified files
ct lsco -cvi -s -avo 2>/dev/null | xargs ct unco -rm # Or: xargs ct ci -nc
exit # Terminate the session in the view
viewname=$(</tmp/viewname)
rm /tmp/viewname
# The next line is the second dangerous line
ct rmview -tag $viewname
ct mkview -tag $viewname $(</tmp/$viewname.vws)
ct setcs -tag $viewname /tmp/$viewname.cs
rm /tmp/$viewname.cs
All view private files are gone - and you've minimized your disk usage.
If you're lucky enough to only work with a single VOB, you can omit the '-avo
' (all VOBs) option. The '2>/dev/null
' redirection loses errors from inaccessible VOBs - I have more than 100 visible but inaccessible VOBs in my environment, apart from the dozen or so accessible ones that I really use.
Note that if you were packaging this as a 'rebuild.view
' script, you'd take the viewname as an argument (working from outside the view - it would not be the current view), and you could then do the cleanup inside the view, use a different 'lsview' option to get the details needed, and generally get away from the temporary storage in /tmp (though you'll need to cache the cspec somewhere).
One other point to note - you would want to ensure that you've done a manual cleanup before letting the automatic loose. There should be no checkouts, for example. Alternatively, write the script to refuse to drop the view if there are any checkouts.