The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-28-2005
Registered User
 

Join Date: Nov 2005
Posts: 27
max value

Hi All,

I want to choose the maximum value from a column values.

eg -

234
23
567
43
2456
5
678
8978

from thses values how to choose the max value ?

thanks.
roger.
Reply With Quote
Forum Sponsor
  #2  
Old 11-28-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
multiple ways given the input file file.txt:
Code:
sort -r file.txt | tail -1
nawk '{if ($0 > max) max=$0}END{print max}' file.txt
Reply With Quote
  #3  
Old 11-29-2005
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
Originally Posted by vgersh99
multiple ways given the input file file.txt:
Code:
sort -r file.txt | tail -1
i am afraid this would fetch only the minimum value from the list (but the req was for maximum value)

try,

Code:
sort -n file.txt | tail -1
Reply With Quote
  #4  
Old 11-29-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
you're right - must have been a long day.
thanks for the correction.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0