Number lines of file and assign variable to each number

I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later.

Ex. 1 some data
2 something else
3 more stuff

which number do you want?

then the user would input the number, and that line would be stored as a variable to be gotten later. But I have many lines to this file so I want bash to just grab a variable from each number on the left hand column.

Reading every line in to variables isn't necessary, how about:

$ cat numbered_file.sh
echo -n "input a number: "
read RESP

VARIABLE=`grep "^${RESP} " numbered_file`

echo "VARIABLE = ${VARIABLE}."
$

Note ^ = beginning of line and space after ${RESP} so when you enter 3 you do not also get lines 30, 31, 32, ..., 300, etc.
Run of script using your example 3 line input file:

$ ./numbered_file.sh
input a number: 3
VARIABLE = 3 more stuff.
$./numbered_file.sh
input a number: 1
VARIABLE = 1 some data.
$ ./numbered_file.sh
input a number: 2
VARIABLE = 2 something else.
$

Is that what you are after?

---------- Post updated at 23:04 ---------- Previous update was at 22:36 ----------

Otherwise you could do this:

$ cat ./numbered_file_array_select.sh

# Load array:
ARRAYPTR=0
while read LINE; do
  ARRAY_ENTRY=`echo ${LINE} | awk '{ print $1 }'`
  ARRAY_LINE=`echo ${LINE} | sed -e 's/^'${ARRAY_ENTRY}' //'`
  ARRAYPTR=`expr ${ARRAYPTR} + 1`
  ARRAYSTORE[${ARRAY_ENTRY}]=${ARRAY_LINE}
done < numbered_file

# Search Array:
echo -n "Input a number up to ${ARRAYPTR}: "
read RESP
VARIABLE=`echo ${ARRAYSTORE[${RESP}]}`

echo "VARIABLE = ${VARIABLE}."
$

Run through:

$ ./numbered_file_array_select.sh
Input a number up to 3: 2
VARIABLE = something else.
$ ./numbered_file_array_select.sh
Input a number up to 3: 1
VARIABLE = some data.
$ ./numbered_file_array_select.sh
Input a number up to 3: 3
VARIABLE = more stuff.