Java - Arrays.binarySearch function equivalent in awk | Unix Linux Forums | Shell Programming and Scripting

  Go Back    

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

Java - Arrays.binarySearch function equivalent in awk

Shell Programming and Scripting

Closed Thread    
Thread Tools Search this Thread Display Modes
Old 09-13-2013
Akshay Hegde's Avatar
Akshay Hegde Akshay Hegde is offline Forum Advisor  
Forum Advisor
Join Date: Nov 2012
Last Activity: 27 January 2015, 7:56 AM EST
Location: Goa / Bangalore, India
Posts: 1,663
Thanks: 82
Thanked 552 Times in 502 Posts
Java - Arrays.binarySearch function equivalent in awk

Hi all

Does anyone know Java-Arrays.binarySearch function equivalent in awk
I tried like this but it's not correct one,it just returns array index if and only when searched value available in array, for some reason if searched value not found then I want to return upper nearest neighbour index. please let me know if anyone have better idea

function Arrays_binarySearch(arr,val){
                    for(b in arr){
                             return b

here is link to example in java

Java.util.Arrays.binarySearch(int[] a, int key) Method Example

please someone help me..

Last edited by Akshay Hegde; 09-13-2013 at 12:49 PM..
Sponsored Links
Old 09-13-2013
spacebar's Avatar
spacebar spacebar is offline
Registered User
Join Date: Oct 2009
Last Activity: 2 June 2014, 3:23 PM EDT
Location: spaceBAR Central
Posts: 440
Thanks: 0
Thanked 70 Times in 70 Posts
Check out this info there are examples for multiple languages:
Binary search - Rosetta Code
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Equivalent function for matlab on scilab abu_malek Programming 0 09-18-2009 11:58 AM
shell script equivalent for tcl function JackMelson Shell Programming and Scripting 1 11-30-2008 05:55 PM
Bash equivalent of perl's pack function ? NewDeb Shell Programming and Scripting 1 11-14-2008 11:23 PM
equivalent function for wherey( ) ?? rockgal Programming 2 11-28-2006 09:13 AM
Equivalent function of [ kbhit() ] In TURBO C niravuchat Linux 0 03-22-2004 09:16 AM

All times are GMT -4. The time now is 02:52 PM.