#!/bin/bash

allneedmodnames=`lsmod | tail -n +2 | cut -d ' ' -f1`
allneedfnames=`for m in \`echo $allneedmodnames\` ; do /sbin/modinfo -F filename $m ; done`

for file in `find /lib/modules/\`uname -r\`/kernel/sound | grep "\.ko"` ; do
    if [[ ! `echo $allneedfnames | grep $file 2>/dev/null`  ]] ; then
	rm -f $file
    fi
done
