[CentOS] Question on script

John Doe jdmls at yahoo.com
Fri Jan 30 15:24:59 UTC 2009





----- Original Message ----
> From: Jerry Geis <geisj at pagestation.com>
> To: CentOS ML <centos at centos.org>
> Sent: Thursday, January 29, 2009 7:55:03 PM
> Subject: [CentOS] Question on script
> 
> 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

Maybe you will be inspired by:
aplay -l | grep HDMI | tr ":," "\n" | grep "^card\|^ device" | awk ' { print $2 } '

0
3
2
3

JD


      



More information about the CentOS mailing list