Thanks Gerry.

With your suggestion a solution was found:

awk -F"|" 'BEGIN {max = 0} $2 ~ /foo/ {if ($1>max) max=$1} END{print max}'

Sincerely,
SDA


On Fri, Oct 30, 2015 at 7:52 PM, gerry <gsker at skerbitz.org> wrote:

> Saul,
> It sounds like you just want the max for the first field?
>   gawk '/foo/{if (max < $1) max=$1} END {print $1}' file
>
> But that doesn't seem likely since it's too simple - no offence intended.
>
> Did you want the 2nd field of the row with the max of the first field?
>   gawk '/foo/{if (max < $1) {max=$1;save3=$3} } END {print save3;}'
>
> I'm ignoring the vertical bars because your example had spaces which awk
> recognizes by default.
> If the spaces are not consistent then you might want to use -F.
>
> You can probably find a good example of what you want
> on http://commandlinefu.com
>
> --
> gsker at skerbitz.org
>
>
> On Fri, 30 Oct 2015, Saul Alanis wrote:
>
>
>> I have a file with multiple fields;
>>
>> 2 | foo | bar
>> 4 | bar | foo
>> 1 | bar | foo
>> 3 | foo | bar
>>
>> My goal is to sort the first field numerically and print the first field
>> of the last result.
>>
>> awk -F"|" '/foo/ {print $1 | "sort"}'
>>
>> awk -F"|" '/foo/ {number=$1} END {print version}'
>>
>> Help is greatly appreciated :)
>>
>> SDA
>>
>>
>>
>> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20151030/ba5a5350/attachment.html>