Walt Mankowski via plug on 10 Sep 2020 10:21:35 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Awk *language*: was Win Subsystem for Linux2 broken


On Thu, Sep 10, 2020 at 01:08:40PM -0400, Mark Bergman via plug wrote:
> AWK is Turing-complete, definitely a 'language'.
> 
> I often find myself reaching for awk for doing stuff with CSV files, like:
> 
> 	awk 'FS=","; BEGIN{high=0}; {sum=sum+$3 ; if ( high < $4 ) { high=$4 ; highline=NR}} ; END{print "The sum is " sum " and the high in column 4 was " high " on line " highline }'

The Perl version of that is similar, which isn't surprising since
Larry Wall took a lot of features from AWK:

perl -F, -aE '$sum += $F[4]; ($high, $highline) = ($F[5], $.) if $high < $F[5]; END{say "The sum is $sum and the high in column 4 was $high on line $highline"}'

Attachment: signature.asc
Description: PGP signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug