On Tue, Jul 18, 2000 at 02:22:09PM -0500, Bret Hughes wrote:
| > kernel-2.2.14-12.i386.rpm
| > kernel-2.2.14-6.0.1.i386.rpm
| > kernel-2.2.14-6.1.1.i386.rpm
| > How do I get a list of only the newest version of each package
| > listed.
| What does ls -t do?  It should sort by modification time of the files.

Except that these are URLs, not files...

Generally, even if you had the modification times of the RPM files they
would not be very relevant because they will only reflect when the RPM
was copied into whichever repository you're examining. There is some
correlation of course, but it's not rigorous.

| Then, if yopu are really tricky, you can figure out when the list begins
| to repeat.

This is more productive.

I would say the 3 RPMs above come from 2 different providers (note the
different naming styles). RedHat RPMs tend to look like

        rpm-version-release.arch.rpm

Are the lower two maybe Mandrake RPMs? Just guessing here.

I would constrain my script to only one RPM provider, eg RedHat.
That way the naming conventions (and install conventions!) will match.

| Just a suggestion I have not tried.  MY gues is that this would be a good
| time to learn perl :)

Jeez I hate this line. Every second scripting article in the list says
"um, too hard for me, try perl!" This is rubbish. I like perl. I write
lots of perl. It is NOT NOT NOT the ideal tool for all tasks.

For a rough cut, take take your list of RPMs, winnow to a single naming
convention (either by taking from just one repository or by grepping
out just the RPMs matching a particular naming scheme). The use sort,
which will sort of many fields and field separators. It's quite
flexible. The filter to prefix each line with the canonical name of the
RPM ("kernel" is the cited example) and then through awk to keep only
the last instance for each canonical name. Then compare with your "rpm
-qa" output.

You can do all this with a monolithic perl script. Or you can learn
about the various tools (sort, grep, sed, awk, comm, diff, join, etc)
and string them together with a shell script.

Frankly, I often find a well written shell script far more reachable and
maintainable than a monolithic perl script.
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

... and I say to them,
   `Where the hell were you
    when the page was blank?'
                Harlan Ellison


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to