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

Re: Cleaning Up Alternatives



On 5/23/07, Wayne Topa <linuxone@intergate.com> wrote:
Mike McClain(mike.mcclain@nowhere.net) is reported to have said:
> On Tue, 22 May 2007, 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?
>
> If these leftovers are due to packages removed but not purged, this
> will tell you:
>     grep -B1 "Status: deinstall ok config-files" /var/lib/dpkg/status \
>         | grep "Pac" | cut -d" " -f2
> and
>     for f in $( the above line ); do dpkg -P $f; done
> will clean up.

Thanks for this jewel Mike!  I am still trying to grok the " -f2.


It's easy enough.  -d" " sets the delimiter to space instead of the
default TAB, and -f2 selects the second field according to that
delimiter.  See the cut(1) manpage.

Try running the pipeline without the final cut to see.

--
Kushal



Reply to: