#!/bin/ksh [ ! -z $1 ] && sndioctl -q server.device=$1 DUMP=$(dmesg) _cur=$(sndioctl -n server.device) examine() { _type=$(echo "$1" | cut -d" " -f3) _number=$(echo "$1" | cut -d" " -f1 | sed 's/[a-z]//g') _desc=$(echo "$DUMP" | grep -E "^$_type at.*" | tail -1 | cut -d'"' -f2) [ -z $_number ] && return if [ $_cur -eq $_number ] then [ ! -z $_number ] && echo "> $_number: $_desc" else [ ! -z $_number ] && echo " $_number: $_desc" fi } for i in 0 1 2 3 4 5 6 do examine "$(echo "$DUMP" | grep -E "^audio$i\ at.*" | tail -1)" done