#!/bin/bash ACTION="$1" shift PACKAGE_LIST=$@ case $ACTION in remove) match=0 for ix in $PACKAGE_LIST do apt-get remove -y $ix TEST=$( dpkg-query -s $ix 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" == 'installed' ];then match+=1 fi done if [ "$match" -gt 0 ];then exit 1 fi ;; esac exit 0