Isolating a specified line - awk grep or somthing else?

I'm trying to isolate attached hard drives that auto-mount to /media so that I can use them as variables in a bash script...

so far I'm here:

variable=$(ls /media | grep -v cdrom )

This lists all the connected drives, each on it's own line and doesn't list anything I don't want (cdrom folders)... is there a way using grep or awk to take the output of my "grep -v cdrom" and print a specific line...

I'll only ever have 6 drives connected at time, so I figure I'd just use the code 6 times to get each drive and keep it simple... Obviously the below script doesn't work but, something like this...

drive1=$(ls /media | grep -v cdrom | awk line1 )
drive2=$(ls /media | grep -v cdrom | awk line2 )
drive3=$(ls /media | grep -v cdrom | awk line3 )
drive4=$(ls /media | grep -v cdrom | awk line4 )
drive5=$(ls /media | grep -v cdrom | awk line5 )
drive6=$(ls /media | grep -v cdrom | awk line6 )

I did quite a bit of searching for this, but I must not using the correct terminology, because I couldn't find anything?

Thanks for any help!
-Starcast

array=( ls /media | grep -v cdrom | tr -s '\n' ' '  )
i=0;
while [[ $i -lt ${array[#]} ]] 
  echo "array element # $1 = ${array}
  i=$(( $i + 1))
done

I think you meant:

array=( $(ls /media | grep -v cdrom | tr -s '\n' ' ')  )

But that is not portable. Most shells do not have arrays. (And there's no need for tr in those shells that do have arrays.)

There's no need for any external commands:

n=1
for d in /media/*
do
  case $d in
    *cdrom*) ;;
    *) eval "drive$n=\$d"; n=$(( $n + 1 )) ;;
  esac
done