<div dir="ltr">Thanks Gerry.<div><br></div><div>With your suggestion a solution was found:</div><div><br></div><div>awk -F"|" 'BEGIN {max = 0} $2 ~ /foo/ {if ($1>max) max=$1} END{print max}' <br></div><div><br></div><div>Sincerely,</div><div>SDA</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 30, 2015 at 7:52 PM, gerry <span dir="ltr"><<a href="mailto:gsker@skerbitz.org" target="_blank">gsker@skerbitz.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Saul,<br>
It sounds like you just want the max for the first field?<br>
gawk '/foo/{if (max < $1) max=$1} END {print $1}' file<br>
<br>
But that doesn't seem likely since it's too simple - no offence intended.<br>
<br>
Did you want the 2nd field of the row with the max of the first field?<br>
gawk '/foo/{if (max < $1) {max=$1;save3=$3} } END {print save3;}'<br>
<br>
I'm ignoring the vertical bars because your example had spaces which awk recognizes by default.<br>
If the spaces are not consistent then you might want to use -F.<br>
<br>
You can probably find a good example of what you want<br>
on <a href="http://commandlinefu.com" rel="noreferrer" target="_blank">http://commandlinefu.com</a><br>
<br>
--<br>
<a href="mailto:gsker@skerbitz.org" target="_blank">gsker@skerbitz.org</a><div><div class="h5"><br>
<br>
On Fri, 30 Oct 2015, Saul Alanis wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I have a file with multiple fields;<br>
<br>
2 | foo | bar<br>
4 | bar | foo<br>
1 | bar | foo<br>
3 | foo | bar<br>
<br>
My goal is to sort the first field numerically and print the first field of the last result.<br>
<br>
awk -F"|" '/foo/ {print $1 | "sort"}'<br>
<br>
awk -F"|" '/foo/ {number=$1} END {print version}'<br>
<br>
Help is greatly appreciated :)<br>
<br>
SDA<br>
<br>
<br>
<br>
</blockquote></div></div>
_______________________________________________<br>
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota<br>
<a href="mailto:tclug-list@mn-linux.org" target="_blank">tclug-list@mn-linux.org</a><br>
<a href="http://mailman.mn-linux.org/mailman/listinfo/tclug-list" rel="noreferrer" target="_blank">http://mailman.mn-linux.org/mailman/listinfo/tclug-list</a><br>
</blockquote></div><br></div>