#!/bin/bash
cat <<EOF>/tmp/known.txt
2.2.2.2
3.3.3.3
4.4.4.5
EOF
#find all the printers
currentPrint=$(lpstat -s | awk 'NR > 1{print $3}' | tr -d :)
for print in $currentPrint;do
#find the IP for each printer
ip=$(lpstat -v | awk -F '/' "/$print/{print \$3}")
#check to see if that IP exists in that document
exists=$(cat /tmp/known.txt | grep "$ip")
if [ ! -z $exists ];then
echo "preparing to remove $print"
lpadmin -x $print
fi
done