View Single Post
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Urgent: Help on grep the nearest value using bash script

 
0
  #2
Apr 3rd, 2008
Hey there,

This was bugging me all last night, and I finally figured out what my problem was

This should do the trick for you:

Shell Scripting Syntax (Toggle Plain Text)
  1. awk 'BEGIN {var=3; highest=0}{ j = $NF;if ( j < var && j > highest ) { highest=j} } END {print highest}' YourInputFile

That gave me

2.842

from the text you pasted in this post. There's probably a more elegant solution out there, but this'll do the trick for now

Best wishes

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote