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

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

http://www.pkill.info/linux/man/1-enscript/

enscript text-file
Answered by Eric Z Ma.

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 Z Ma

Eric is a father and 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 *