Всем радоваться!
#!/bin/bash
dpkg -l | awk /ii/'{print $2}'>file
lines=`wc -l file | awk '{print $1}'`
echo "Total packages - "$lines
echo -n "Searching for non-free components... "
for i in `seq 1 $lines`; do
line=$i"p"
package=`sed -n $line file`
if apt-cache policy $package | egrep "(contrib|non-free)">/dev/null; then
echo " "$package>>packages
fi
done
echo "done"
echo "What found:"
cat packages
rm file packages