That works (with a few plus minus corrections); however, I need to get the average number from the same file that computes the xmin xmax variables. I'm having trouble at that point. I don't know how to make the script read from the top of the input file once it's calculated the average numbers and to use those average numbers in calcuating the min max numbers.
---
I've included a sample of the input file below (it's listed right after the attempted awk script). Final product should be the min an max of $4 (-109.xxx) and min and max of $5 (39.xx) that can be read through another script. This is what I've done so far using your 1st suggestion.
Can you help???????
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxawk script
awk '
# create average long and lat for min max calculations
BEGIN { print xtot ytot } # begin statement tells me to do this before other statements
{
xtot += $4 #sets up sumation and counter for longitude
++counter
}
{
ytot += $5 #sets up sumation and counter for latitude
++counter
}
/rows selected/ { AC = $1 } #this row actually contains rowcount
END {
{ xavg = xtot/AC }
{ yavg = ytot/AC }
#this is where I need it to read the top of the input file and only include lines with the word TOBIN included ($1 ~ "TOBIN"

/TOBIN/
BEGIN { xmin = xavg }
{
if ( $4 > xmin ) { xmin = $4 }
}
END {
print xmin } ' township.out > header.lst
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsample of township.out
OBJECT_CLASS SEGMENT SEQ_NO X_POLYGON Y_POLYGON TEXT_STRIN X_TEXT_LABEL Y_TEXT_LABEL
------------------------- ---------- ---------- ---------- ---------- ---------- ------------ ------------
UT391_TOBIN_TOWN 102 1 -109.61769 39.7226868 12S 21E -109.56071 39.766235
UT391_TOBIN_TOWN 102 2 -109.61769 39.7517548
UT391_TOBIN_TOWN 102 3 -109.61752 39.7661743
UT391_TOBIN_TOWN 102 4 -109.61763 39.7806702
4 rows selected.