On Mon, 22 Nov 2004, Gavin Henry wrote:

> I have a log file a like this:
> 
> The following packages were available in this version but NOT upgraded:
> Canna-devel-3.7p3-6.i386.rpm
> GConf-devel-1.0.9-15.i386.rpm
> Guppi-devel-0.40.3-21.i386.rpm
> HelixPlayer-1.0.1.gold-6.i386.rpm
> Maelstrom-3.0.6-6.i386.rpm
> MagicPoint-1.11b-1.i386.rpm
> NetworkManager-0.3.1-3.i386.rpm
> NetworkManager-gnome-0.3.1-3.i386.rpm

I know it's not the fasionable way to do this, but I just like doing 
this sort of thing on the command line with shell tools. 

Let's say the command to get the lines out of the file is:

  grep '\.rpm$' logfile

(If it's not that, amend as needed.)

Try something like this to get the raw list:

  $ grep '\.rpm$' logfile | sed 's/\-[0-9].*//' | fmt -1000
  Canna-devel GConf-devel Guppi-devel HelixPlayer Maelstrom MagicPoint 
NetworkManager NetworkManager-gnome
  $

And something like this to actually install it:

  $ rpm -i `grep '\.rpm$' logfile | sed 's/\-[0-9].*//' | fmt -1000`

(Or whatever the `rpm` command is -- I mainly use Debian, not RedHat, so 
I forget how to use RPM these days...).
 
> Can I make a regex for this, (don't tell me how, I'm just not sure 
> which way to go) or should I carry one with substition?

Yeah, you can; the `sed` command above should point you the right way.
 
> Also, could I match rpm and substitute so many characters in front of it as 
> well, like match rpm + 7 chars?

Sure, but why seven?

    $ echo MagicPoint-1.11b-1.i386.rpm
    MagicPoint-1.11b-1.i386.rpm
    $ echo MagicPoint-1.11b-1.i386.rpm | sed 's/.*\(.......rpm\)/\1/'
    1.i386.rpm

Or some variant on that...

 

-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to