[CentOS] Question on script

Thu Jan 29 18:55:03 UTC 2009
Jerry Geis <geisj at pagestation.com>

Hi all,

I am trying to extract from the aplay -l output the Card and Device numbers.
I had a script that was working but found another motherboard that has 
an EXTRA word.
HDA Nvidia and HDA ATI HDMI is what I am talking about below.

how do I search for a line that has HDMI (which I know how to do), then
ignore everything upto the device work and take the next field after that?

Thanks,

Jerry

I was doing this but it does not work for both cases.
        AUDIO_HDMI=`aplay -l | grep -c HDMI`
        if [ "$AUDIO_HDMI" -ge 1 ]
        then
                AUDIO_DEVICE=`aplay -l | grep HDMI | grep " device " | 
grep -m 1 -v "device 0" | tr -d ':' | cut -d ' ' -f 8`
                AUDIO_CARD=`aplay -l | grep HDMI | grep " device " | 
grep -m 1 -v "device 0" | tr -d ':' | cut -d ' ' -f 2`
                sed "0,/hw:/s/hw:.*/hw:$AUDIO_CARD,$AUDIO_DEVICE\"/" < 
/etc/asound.conf > tt.txt
                mv tt.txt /etc/asound.conf


card 0: NVidia [HDA NVidia], device 3: NVIDIA HDMI [NVIDIA HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

card 2: HDMI [HDA ATI HDMI], device 3: ATI HDMI [ATI HDMI]
  Subdevices: 0/1
  Subdevice #0: subdevice #0