Re: awk?

2018-04-13 Thread ToddAndMargo

On 04/13/2018 04:13 AM, Fernando Santagata wrote:

"There's More Than One Way To Do It"



The definition of Perl!

:-)


Re: awk?

2018-04-13 Thread ToddAndMargo

On Friday, April 13, Fernando Santagata wrote:

Hi,

Since "There's More Than One Way To Do It", one can look for the value,
instead of the separator:

$ echo "total kB  1804482980 112" |perl6 -n -e 'say
.comb(/\d+/)[1]'
2980


On Fri, Apr 13, 2018 at 12:31 PM, Shlomi Fish 
wrote:


Hi Todd,

On Fri, 13 Apr 2018 03:00:22 -0700
ToddAndMargo  wrote:


echo "total kB  1804482980 112" | awk '{print $4}')


shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" |
perl6
-n -e 'say .split(/\s+/)[3]'

2980

shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" |
awk
'{print $4}'

2980

See https://docs.perl6.org/language/5to6-nutshell#-a and
http://perldoc.perl.org/perlrun.html .




Fernando Santagata

On 04/13/2018 05:20 AM, Brian Duggan wrote:

One could also use .words --

$ echo "total kB  1804482980 112" |perl6 -n -e 'say .words[3]'
2980

Brian



That almost exactly matches awk and I don't have to
wonder about what each value is made up of.  I love it.
Thank you!

-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: awk?

2018-04-13 Thread ToddAndMargo
On Fri, Apr 13, 2018 at 12:31 PM, Shlomi Fish > wrote:


Hi Todd,

On Fri, 13 Apr 2018 03:00:22 -0700
ToddAndMargo >
wrote:

> echo "total kB  1804482980 112" | awk '{print $4}')

shlomif[Perl6]:$trunk$ echo "total kB  1804482980   
  112" | perl6

-n -e 'say .split(/\s+/)[3]'

2980

shlomif[Perl6]:$trunk$ echo "total kB  1804482980   
  112" | awk

'{print $4}'

2980

See https://docs.perl6.org/language/5to6-nutshell#-a
 and
http://perldoc.perl.org/perlrun.html
 .




On 04/13/2018 04:13 AM, Fernando Santagata wrote:

Hi,

Since "There's More Than One Way To Do It", one can look for the value, 
instead of the separator:


$ echo "total kB  180448    2980 112" |perl6 -n -e 'say 
.comb(/\d+/)[1]'

2980



So the second d+ is [1].  Fascinating.  Thank you!


Re: awk?

2018-04-13 Thread ToddAndMargo

On 04/13/2018 03:31 AM, Shlomi Fish wrote:

Hi Todd,

On Fri, 13 Apr 2018 03:00:22 -0700
ToddAndMargo  wrote:


echo "total kB  1804482980 112" | awk '{print $4}')


shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" | perl6
-n -e 'say .split(/\s+/)[3]'

2980

shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" | awk
'{print $4}'

2980

See https://docs.perl6.org/language/5to6-nutshell#-a and
http://perldoc.perl.org/perlrun.html .



Aw bugger!  I forgot about split!  And I use it all the time.

Thank you!



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: awk?

2018-04-13 Thread Brian Duggan
One could also use .words --

$ echo "total kB  1804482980 112" |perl6 -n -e 'say .words[3]'
2980

Brian

On Friday, April 13, Fernando Santagata wrote: 
> Hi,
> 
> Since "There's More Than One Way To Do It", one can look for the value,
> instead of the separator:
> 
> $ echo "total kB  1804482980 112" |perl6 -n -e 'say
> .comb(/\d+/)[1]'
> 2980
> 
> 
> On Fri, Apr 13, 2018 at 12:31 PM, Shlomi Fish 
> wrote:
> 
> > Hi Todd,
> >
> > On Fri, 13 Apr 2018 03:00:22 -0700
> > ToddAndMargo  wrote:
> >
> > > echo "total kB  1804482980 112" | awk '{print $4}')
> >
> > shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" |
> > perl6
> > -n -e 'say .split(/\s+/)[3]'
> >
> > 2980
> >
> > shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" |
> > awk
> > '{print $4}'
> >
> > 2980
> >
> > See https://docs.perl6.org/language/5to6-nutshell#-a and
> > http://perldoc.perl.org/perlrun.html .
> >
> > --
> > -
> > Shlomi Fish   http://www.shlomifish.org/
> > What does “Zionism” mean? - http://shlom.in/def-zionism
> >
> > Gödel’s Incompleteness Theorem is about to be replaced by the
> > [Clarissa] Darling “Like, Totally!” Completeness Theorem.
> > — http://www.shlomifish.org/humour/bits/facts/Clarissa/
> >
> > Please reply to list if it's a mailing list post - http://shlom.in/reply .
> >
> 
> 
> 
> -- 
> Fernando Santagata


Re: awk?

2018-04-13 Thread Fernando Santagata
Hi,

Since "There's More Than One Way To Do It", one can look for the value,
instead of the separator:

$ echo "total kB  1804482980 112" |perl6 -n -e 'say
.comb(/\d+/)[1]'
2980


On Fri, Apr 13, 2018 at 12:31 PM, Shlomi Fish 
wrote:

> Hi Todd,
>
> On Fri, 13 Apr 2018 03:00:22 -0700
> ToddAndMargo  wrote:
>
> > echo "total kB  1804482980 112" | awk '{print $4}')
>
> shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" |
> perl6
> -n -e 'say .split(/\s+/)[3]'
>
> 2980
>
> shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" |
> awk
> '{print $4}'
>
> 2980
>
> See https://docs.perl6.org/language/5to6-nutshell#-a and
> http://perldoc.perl.org/perlrun.html .
>
> --
> -
> Shlomi Fish   http://www.shlomifish.org/
> What does “Zionism” mean? - http://shlom.in/def-zionism
>
> Gödel’s Incompleteness Theorem is about to be replaced by the
> [Clarissa] Darling “Like, Totally!” Completeness Theorem.
> — http://www.shlomifish.org/humour/bits/facts/Clarissa/
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>



-- 
Fernando Santagata


Re: awk?

2018-04-13 Thread Shlomi Fish
Hi Todd,

On Fri, 13 Apr 2018 03:00:22 -0700
ToddAndMargo  wrote:

> echo "total kB  1804482980 112" | awk '{print $4}')

shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" | perl6
-n -e 'say .split(/\s+/)[3]'

2980

shlomif[Perl6]:$trunk$ echo "total kB  1804482980 112" | awk
'{print $4}'

2980

See https://docs.perl6.org/language/5to6-nutshell#-a and
http://perldoc.perl.org/perlrun.html .

-- 
-
Shlomi Fish   http://www.shlomifish.org/
What does “Zionism” mean? - http://shlom.in/def-zionism

Gödel’s Incompleteness Theorem is about to be replaced by the
[Clarissa] Darling “Like, Totally!” Completeness Theorem.
— http://www.shlomifish.org/humour/bits/facts/Clarissa/

Please reply to list if it's a mailing list post - http://shlom.in/reply .