Re: Find latest RPM in directory

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

 



If there are characters like '-' in part of package name you can
improve this script by replacing

 for x in `ls -1 | cut -f1 -d '-' | sort | uniq`

 with

for x in `ls -1 | sed -e "s/-[0-9]/@/g" | cut -f1 -d '@' | sort | uniq`

so it will cut of part behind dash if there are numbers (version
number) after dash.

2010/5/20 Marcin Stempkowicz <m.stempkowicz@xxxxxxxxx>
>
> Hm.. do you really need perl? Simple sh in directory your isn't something that you need
>
> #!/bin/sh
> for x in `ls -1 | cut -f1 -d '-' | sort | uniq`
> do
> ls -1 ./$x*.rpm | tail -1
> done
>
> ?
>
> I'm not sure about naming in rpm cause I'm using Debian. If there are characters like '-' in part of package name (like my-package-0.89-2.i386.rpm) this will give you wrong results. Good luck!
>
> 2010/5/20 Alex <mysqlstudent@xxxxxxxxx>
>>
>> Hi all,
>>
>> I'm not really a perl programmer, but know that perl and the perl-RPM
>> package would be really good at finding the latest RPM package among
>> all those in directory, and printing them out. Does anyone know of an
>> existing script that can do such a thing?
>>
>> I'd like to be able to run something like:
>>
>> # find-latest-pkg openssh-clients
>>
>> and have it print out only the latest, instead of all ten versions
>> that may be in the directory. Even better, it would be great to print
>> out only the latest unique packages in directory, and not have to
>> specify the package name at all!
>>
>> Perhaps more applicable to an RPM mailing list, or one specific to
>> perl-RPM, but hopefully you also consider this linux-admin material.
>>
>> Thanks so much.
>> Best regards,
>> Alex
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux