get last field using cut

echo '' | rev | cut -d'.' -f1 | rev

print using command line linux

To list avaiable printers

lpstat -p

To print a plain text in one printer

echo 'oi' | lp -d printerNameHere

To print a pdf file in one printer

lp -d printerNameHere file.pdf

To print to parallel printer

echo 'oi' > /dev/lp0

To view printer log

tail -f /var/log/cups/page_log

if you print to a pdf printer the files will be saved in: /var/spool/cups-pdf