Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
Cool. Time to make a bash alias for all this. If you happen to know a gui way, that would be great, also. –  TreefrogInc May 12 '12 at 13:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.