[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cleaning Up Alternatives

On Tue, 22 May 2007 09:47:49 -0400
Celejar <celejar@gmail.com> wrote:

> On Tue, 22 May 2007 12:49:18 +0300
> David Baron <d_baron@012.net.il> wrote:
> > /etc/alternatives has a zillion dangling symlinks. Seems these got set 
> > somewhere along the line but were never cleaned up as programs were moved, 
> > upgraded, removed.
> > 
> > How does one clean up this mess conveniently?
> Anacron sometimes helpfully informs me of similar issues. I suppose it
> should be simple enough to hack together a trivial shell / perl /
> python script to loop through the directory, find all dangling
> symlinks, and delete them; if no one posts some code, I'll try it
> myself eventually. OTOH, this isn't the "Debian way", and I don't know
> if there's any potential for upgrade problems or some other
> interference with the package management system.

Ok, here goes. I'm sure there are cleaner ways to do this ...

find /etc/alternatives/ -maxdepth 1 | perl -n -e 'chomp; print $_ , "\n" if !(-e)'

Do this first to make sure it's correct (it seems to be correct on my
system); if we mess up we can seriously hose our systems.

IFF you get a correct list of dangling symlinks, then do

find /etc/alternatives/ -maxdepth 1 | perl -n -e 'chomp; print $_ , "\n" if !(-e)' | xargs /bin/rm

You might want a second opinion before trying this; messing around with
homebrewed scripts (especially mine0 as root in /etc is living
dangerously ...

> Celejar


mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator

Reply to: