Ubuntu: Can Synaptic sort packages by time?



Question:

I know Software Center can do this (in the "History" section), but I've yet to find a filter/column in Synaptic that will sort the packages by the time they were installed/removed. I could really use this for, say, batch-removing stuff I recently installed but couldn't remember the name/dependencies.

Can I set up a custom filter/column/property/whatever for this, or what? I get the feeling that, at the very least, you should be able to do this from the terminal. If not, how come Software Center is able to do this?

Something Like this: See, USC can do it!


Solution:1

I get the feeling that, at the very least, you should be able to do this from the terminal.

Yes, that's fairly easy to do by looking at the timestamps in /var/lib/dpkg/info/. For example,

  ls -lct /var/lib/dpkg/info |egrep -o "May.*\." |      cut -d. -f1 | uniq | more  

-lct sorts by ctime, "May" is the current (or recent) month you're looking for, cut simply removes the annoying period at the end, and uniq removes duplicates. This gives you something like:

  ...  May 11 18:03 libcogl-pango0:amd64  May 11 18:03 libcogl9:amd64  May 11 18:03 libcaribou0:amd64  May 11 18:03 libcaribou-common  May 11 03:35 libcpufreq0  May 11 03:35 cpufrequtils  ...  

Suppose you want to batch-remove all the packages installed on May 11 at 18:03, you would do something like this:

  apt-get remove `ls -lct /var/lib/dpkg/info |   egrep -o "May.*18:03.*\." |   cut -d. -f1 | uniq |   cut -d' ' -f4 | tr '\n' ' '`  

where the 2nd cut simply selects the package names and tr converts the linebreaks to spaces to give you a list suitable for apt-get.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »