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
  #3
Apr 3rd, 2008
Actually, oops, you can change the

Shell Scripting Syntax (Toggle Plain Text)
  1. j < var

part to

Shell Scripting Syntax (Toggle Plain Text)
  1. j <= var

just noticed that

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

, 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