while loops

Hi

I've a file like so:

Now, I want to read my file and take ex. the Media ID and the Type for each groups of Media (Media1,Media2,...,Media(n):

cat /tmp/file|\
while read FILE
do
  while $(FILE|cut -d: -f1)=Media$i
  do
    #here will be some test, ex:
    #if Media ID < 23
    #then...
  done
  let i=i+1
done

The second while loops doesn't run and I don't know how to do that.
Should I use sed, awk ? I don't must to use Perl?
And my second question is how to do a good shell script, how to know for which case which things (sed,awk,etc...) is better to use.
Yeah, it's a big questions but I really want to go further....
Best regards

Try

while [ "$(echo ${FILE}|cut -d: -f1)." = "Media$i." ]

I've try but it doesn't run!

opss wrong code!

#! /usr/bin/ksh

exec < file
while read line ; do
        [[ "$line" = *"Media ID="* ]] && echo ${line#*=}
        [[ "$line" = *"Type="* ]] && echo ${line#*=}
done
exit 0