[ale] Using sed to print package names

Brian Pitts brian at polibyte.com
Sun Sep 6 22:56:14 EDT 2009


On 09/06/2009 11:13 AM, Matty wrote:
> Howdy,
> 
> Does anyone happen to have a sed recipe to split a package name like:
> 
> yum-metadata-parser-1.1.2-12.fc11.x86_64
> 
> Into:
> 
> $1 -> yum-metadata-parser
> $2 -> -1.*
> 
> I have a working solution in perl and python, but sed is another story.
> 

Could you use grep instead of sed? If so, you might be able to reuse
your perl regexp with grep --perl-regexp. Also, here are two simple
egrep expreesions that seem to work.

$ echo 'yum-metadata-parser-1.1.2-12.fc11.x86_64' | grep -Eo '[-a-z]+[a-z]'

yum-metadata-parser
fc

$ echo 'yum-metadata-parser-1.1.2-12.fc11.x86_64' | grep -Eo
'[0-9]+[-.1-9]+fc[0-9]{1,2}.(x86_64|i386)'

1.1.2-12.fc11.x86_64

-- 
All the best,
Brian Pitts


More information about the Ale mailing list