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

Re: Uninstall (nearly) everything installed after spacific date



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bob wrote:
> Joe Hart wrote:
>> Hash: SHA1
>> Bob wrote:
>>  
>>> Hi,
>>> How can I do this, the way I'd like it to work is
>>> cat /var/log/dpkg.log > ./list
>>> but filtering by date so it only includes packages installed after a
>>> certain time (grep sed?)
>>>
>>> vi ./list
>>> to delete lines for packages you want to keep (running kernel, less,
>>> hddtemp, whatever...)
>>>
>>> pass the ./list file to a command that will beautify it and output
>>> another list of just package names that you can pass to
>>> apt-get --purge remove
>>>
>>> Shouldn't be too hard but my bash is rusty, so I thought I'd ask if
>>> anyone had done this already before I crack my knuckles and get all man
>>> bash sed grep on it?
>>>
>>>     
>> Perhaps something list this:  (adapt it for your needs)
>>
>> #!/bin/bash
>> dpkg -l | grep beryl | gawk -F" " '{ print $2 }' > beryl.list
>> apt-get remove --purge $(cat beryl.list)
>> rm beryl.list
>> #end
>>   
> 
> Thanks for that, I'll see what I can do, I found this on the web
> somewhere, it lists installed packages, including dependency's by the
> install date.
> ls -l -t /var/lib/dpkg/info/*.list > ./inst.txt
> so I can use that as a start point, it's probably easer to delete all
> references to packages installed before the cut off by hand, but I don't
> necessarily want the *easiest* way, or even the best way, I want the
> most educational and accurate way.
> 
> 

I can't understand exactly why you want to do this, but it's your
system.  The little script above will take dpkg -l output and format it
only pulling the names of the files that are specified by the grep.  If
you change it so that dpkg outputs the files by date, then you don't
need the grep, and should manually edit the .txt file that is created
before running the apt-get remove --purge.

However, looking at what that command does, it's not going to help you.
 All that does is list the .list files that dpkg created when it
installed a package.  Each .list file contains the filenames of all
files that were in the package, but not the package.  However, the
package names are there.  This on the other hand:

ls -lt  /var/lib/dpkg/info/*.list | awk -F"/" '{print $6}' | awk -F"."
'{print $1}' > list.txt

will give you a list of packages in cronological order.  That you can
then edit and feed to apt-get.  Like I said, I don't know why you want
to do it, but I found it fun creating that line.

I'm getting better with awk.  :)

That command should be all one line.  I can't quite figure out how to
get it to pull only after a certain date.  It does them all.

Perhaps another method altogether would better suit your needs.  There
is a package called partimage that will take a snapshot of a partition.
 You can do that on a frequent basis and always restore from a previous
image, but the catch is you can run it on a mounted partition, so you
need a liveCD to catch the / partition.

I use grml for that, knowing that if I ever bork my system I can always
boot grml and run partimage and restore it back to what it was the when
I created the image.  It works.

Joe
- --
Registerd Linux user #443289 at http://counter.li.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF/RXriXBCVWpc5J4RAtR5AKCdx9hsh+VuH8d5+9QRhrA9fK5rZgCePw8z
Ut3WKIgP6TzYs7aia1PmZ60=
=ju60
-----END PGP SIGNATURE-----



Reply to: