Remove Printer Sctip

db65681
New Contributor

Hi,

I'm trying to deploy a script that will remove specific printers. The problem I'm running into is that not all of them are named the same. For example, we have Printer1_Ricoh and Printer1_Ricoh_Bob. I'm using lpadmin -x Printer1_Ricoh in the script, but that doesn't get rid of it from people who have it named Printer1_Ricoh_Bob or Printer1_Ricoh_Joe. Is there a way to do the lpadmin command to remove a printer with a regular expression/wild card? Such that it will remove any printer with a name that contains Printer1_Ricoh.

Thanks in advance.

1 REPLY 1

db65681
New Contributor

If anyone is interested, I found a solution:

lpstat -p | cut -d' ' -f2 | grep Printer1_Ricoh | xargs -I{} lpadmin -x {}