Inside of a script I send a certain file to print using the
lpr command on an user-selected printer.
The list of the printers, from which the user selects the one to use, I get using the
lpstat -a command and then considering everything before the first space as the name of the printer.
This works but relies heavily on the specific output format of the
lpstat -a command. I'm afraid that in the future (or now on different distributions) if the output format changes it will break the script.
So, is there a way to get the names of all the installed printers in a way that is safer than the one I'm using?