title: How to do in-memory binary search in Bash?
body: <p>Write a bash script to do a binary search. Read student names and grades from a file into an array. Prompt the user for a student name. Find the name in the array and display the grade. The data in the file is below:</p>
  
  <pre><code>Ann:A
  Bob:C
  Cindy:B
  Dean:F
  Emily:A
  Frank:C
  Ginger:D
  Hal:B
  Ivy:A
  Justin:F
  Karen:D
  </code></pre>
  
  <p>I have done the following but I am stuck on what to do next</p>
  
  <pre><code>#!/bin/bash
   echo "please enter students Name: "
   read student
   echo "$student + $Grade"
   ((i=0))
   while read students[$i] ; do
   ((i++))
  
   done &lt; students.dat
   first=0
   last=$(students[@])
  
  
   ((mid=0))
   Name=`echo ${students[$mid]} | cut -d: -f1`
   Grade=`echo ${students[$mid]} | cut -d: -f2`
   echo $Name
   echo $Grade
  </code></pre>