On 08/04/2017 08:43 PM, Bruce Gray wrote:

On Aug 4, 2017, at 9:12 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

Hi All,

How would you convert this one liner over to a Perl 6 one
liner with a pipe?

ifconfig | grep flags | awk '{print $1}' | sort | sed -n 2,2p | sed -e 's/://‘
—snip—

First attempt; straight translation:
ifconfig | perl6 -e 'say lines().grep({/flags/}).map({.words.[0].subst(/":"$/, 
"")}).sort.[1]'

P6-ish version:
ifconfig | perl6 -e 'say lines.map({ ~$0 if /^(\S+) ": flags="/ }).sort[1]'

$ ifconfig | grep flags | awk '{print $1}' | sort | sed -n 2,2p | sed -e 's/://'
enp6s0

$ ifconfig | /usr/bin/perl6 -e 'say lines.map({ ~$0 if /^(\S+) ": flags="/ }).sort[1]'
enp6s0

$ ifconfig | /usr/bin/perl6 -e 'say lines.map({ ~$0 if /^(\S+) ": flags="/ }).sort[2]'
enp7s0

Thank you!

I have no idea what you just did.

-T

Reply via email to