[ale] Using sed to print package names

scott mcbrien smcbrien at gmail.com
Sun Sep 6 23:31:13 EDT 2009


Again, I suggest using rpm with --queryformat with something that's not part
of the package, like a space or * or something that you could use as your
field delimiter.  Then the rules for your regular expression make it trivial
to get out the bits you want.  Like:
rpm -qa --queryformat '%{name} %{version}-%{release} %{arch}\n'

-Scott

On Sun, Sep 6, 2009 at 10:56 PM, Brian Pitts <brian at polibyte.com> wrote:

> 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
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20090906/cfe8e06c/attachment.html 


More information about the Ale mailing list