Tuesday, January 24, 2012

TL;DR Here's the code:
search="font"; for x in $({ apt-cache search $search | grep $search | cut -f1 -d' ' ; dpkg -l | grep $search | awk '{print $2}' ; } | sort | uniq -u ); do apt-cache show $x  | sed -n '/Package/p;/^Description-en:/,/^Description-md5:/p'; done


Unfortunately not every package info given by apt-cache show has the same layout, so sometimes Package: is printed twice and sometimes all the package's info is printed out. We'll have to work on that.

So let's say you wanted to do the following in Debian/Ubuntu:
compare the packages you have installed pertaining to term "A" (dpkg -l | grep $A) with a list of all available packages pertaining to term "A" (apt-cache search $A | grep $A) and then print a list of those which are NOT currently installed but which pertain to term A.
The easy way to say that is "print me all packages i don't have installed containing $A in their name or short description". I believe this would be accomplished in yum with ``yum show uninstalled | grep $A'' but not totally sure.

Furthermore, I want to take that list and print the descriptions of those packages with their Package Name, so I can browse what I want to install.

Yes yes you may say I could use a software center or synaptic but whatever. This is way easier and I figured out two important things about both sed and bash.

No comments:

Post a Comment