Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Java - Arrays.binarySearch function equivalent in awk

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 09-13-2013
Akshay Hegde's Unix or Linux Image
Akshay Hegde Akshay Hegde is offline Forum Advisor  
Forum Advisor
Join Date: Nov 2012
Last Activity: 8 October 2016, 2:15 AM EDT
Posts: 1,785
Thanks: 97
Thanked 621 Times in 554 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 11:49 AM..
Sponsored Links
Old Unix and Linux 09-13-2013
spacebar's Unix or Linux Image
spacebar spacebar is offline
Registered User
Join Date: Oct 2009
Last Activity: 21 September 2016, 12:03 PM EDT
Location: spaceBAR Central
Posts: 440
Thanks: 0
Thanked 71 Times in 70 Posts
Check out this info there are examples for multiple languages:
Binary search - Rosetta Code
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 10:58 AM
shell script equivalent for tcl function JackMelson Shell Programming and Scripting 1 11-30-2008 04:55 PM
Bash equivalent of perl's pack function ? NewDeb Shell Programming and Scripting 1 11-14-2008 10:23 PM
equivalent function for wherey( ) ?? rockgal Programming 2 11-28-2006 08:13 AM
Equivalent function of [ kbhit() ] In TURBO C niravuchat Linux 0 03-22-2004 08:16 AM

All times are GMT -4. The time now is 05:32 PM.