LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 07-21-2008, 05:55 AM   #1
samac
Senior Member
 
Registered: Mar 2004
Location: Westray, Orkney
Distribution: Slackware64-14.1 (multi-lib) KDE 4.11.4
Posts: 1,422

Rep: Reputation: 137Reputation: 137
Need a script to remove packages by date


I had slimmed down my system to a my needs and then I had a crazy idea, I thought that I would try and compile OpenOffice from source.

So if I managed this I could write a howto. I thought to myself that it would have to be on a full install, so I re-installed all the stuff that I had taken out.

All was going remarkably well until OpenOffice decided that it couldn't find Apache Ant, even when it was told explicitly where it was. I got grumpy at this stage and removed all the packages that I had created.

Now I want my nice slim system back. I have a list of the packages that I want to delete created with
Code:
ls -al /var/log/packages | grep 2008-07-20 > delete.list
and I suspect that I will have to use "cut" and pipe the output to "removepkg", however I am not a programmer and if I see something that looks like "for i in ..." I usually find something better to do.

Could someone give me some pointers as to how to proceed.

Thanks

samac
 
Old 07-21-2008, 06:20 AM   #2
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
This works for me - have a look at delete.list with vim and make sure the package names are aligned on byte 50. They are on my system. Then this will remove them when ran as the superuser.

Code:
cut --bytes=50- delete.list | while read line; do removepkg $line;done
 
Old 07-21-2008, 06:41 AM   #3
samac
Senior Member
 
Registered: Mar 2004
Location: Westray, Orkney
Distribution: Slackware64-14.1 (multi-lib) KDE 4.11.4
Posts: 1,422

Original Poster
Rep: Reputation: 137Reputation: 137
Perfect thanks very much. If I were to try and read that line in plain english would it read:

Cut from the 50th byte onwards in the file delete list, redirect that output per line and read it, then do a remove package on each line that is read.

I knew it could be done, but it is knowing where to start, I was sure that you would need integers and loops etc. Just shows you what I know about programming.

Thanks again

samac
 
Old 07-21-2008, 08:33 AM   #4
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
Yeah - your English description of what happens pretty much sums it up. The main workings are in the while read line bit which reads a line from stdin (the output of cut is piped to this). The line variable then holds the remainder of the line cut from byte fifty till the end. The $ sign on the line variable expands it replacing it's contents to the removepkg script.

Thinking about this some more - this should work and is shorter :

Code:
cut --bytes=50- delete.list | xargs removepkg

Last edited by bgeddy; 07-21-2008 at 09:02 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to remove old files based on date WindozBytes Linux - General 12 06-04-2012 01:21 AM
shell script to find modified date and last accessed date of any file. parasdua Linux - Newbie 6 04-22-2008 09:59 AM
Script to Remove a List of Debian Packages zael Programming 6 05-27-2004 05:36 PM
Mandrake Update/Install Packages/Remove Packages wslyhbb Mandriva 2 03-15-2004 09:43 AM
Debian Packages (apt-get) not up-to-date? rmdl Debian 12 02-23-2004 08:59 AM


All times are GMT -5. The time now is 01:28 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration