On Thu, 2020-04-30 at 01:10 +0200, Miro Hrončok wrote:
> On 30. 04. 20 1:07, Neal Gompa wrote:
> > > my usual mistake is where I do a stupid programming and do something like
> > > 
> > > ls -1 | awk '{split($0,a,"."); print a[1]}' | whatever I needed for just 
> > > the names of rpms
> > > 
> > > which for most packages will give me the Name-Ver[.sion removed]. it is 
> > > lazy script programming but it works often enough that my brain wants it 
> > > to work all the time than doing something like
> > > 
> > > ls -1 *rpm | xargs rpm --qf='%{NAME}\n' -qp | whatever i needed for just 
> > > the names of the rpms.
> > > 
> > Splitting on the second to last dash of an rpm file name will*always*
> > give you the name on the left side, and the version-release on the
> > right side, so I usually do a split that way.
> 
> I have this in my PATH (called pkgname):
> 
> #!/usr/bin/python3
> import fileinput
> 
> 
> for line in fileinput.input():
>      print('-'.join(line.split('-')[:-2]))

how about:

    print(line.rsplit("-", 2)[0])

?
-- 
Adam Williamson
Fedora QA Community Monkey
IRC: adamw | Twitter: AdamW_Fedora | XMPP: adamw AT happyassassin . net
http://www.happyassassin.net
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org

Reply via email to