How to print a plain text file to printers from a terminal in Linux

Posted on In QA

How to quickly print a plain text file to printers from a terminal in Linux?

You can also use enscript:

enscript – convert text files to PostScript, HTML, RTF, ANSI, and overstrikes

https://www.systutorials.com/docs/linux/man/1-enscript/

enscript text-file

The lp command can print a plain text file to a printer.

My favorite command:

cat text-file | lp -o media=a4 -o cpi=12 -o lpi=7.2 -o page-left=48 -o page-right=48 -o page-top=48 -o page-bottom=48

It is better to put the options into a script.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *