The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-03-2009
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 166
Something like this ?

Code:
$ cat ash.txt
1 2 3 45 32
2 3 5 36 87
5 8 3 96 23
8 9 6 24 56

for 4th column: 

$ awk 'min=="" || $4 < min {min=$4} END{ print min}' ash.txt
24

$ awk 'max=="" || $4 > max {max=$4} END{ print max}' ash.txt
96

or

$ awk '
min=="" {
min=max=$4
}
{
if ($4 > max) {max = $4};
if ($4 < min) {min = $4};
}
END {
print "minimum:" min;
print "maximum:" max;
}
' ash.txt

minimum:24
maximum:96