How to list installed ports that have no dependant ports

Mike Meyer mwm-dated-1049912455.a8b6ce at
Fri Apr 4 10:20:58 PST 2003

In <1049438180.27963.60.camel at jake>, Adam <blueeskimo at> typed:
> So, what I'd like to do is list all the ports installed on my box that
> have nothing dependant on them. In this way, I could start removing
> things that I don't need anymore. 
> Is there any clever way to do this? I've toyed around with a few ideas,
> but haven't been able to come up with anything that works nicely.

Since you want to delete them, why don't you just use pkg_delete on
them. If they something depends on them, they won't be deleted.

So the recommended methodology is:

Put a sorted list of ports you know you want to keep in "keeps".

Generate a list of things to try and delete by

(cd /var/db/pkg; ls | sort) | comm -23 - keeps | xargs pkg_delete

and keep doing that as long as things are vanishing from /var/db/pkg.

Mike Meyer <mwm at>
Independent Network/Unix/Perforce consultant, email for more information.

More information about the freebsd-questions mailing list