home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Unix Power ToolsUnix Power ToolsSearch this book

45.7. Formatting Plain Text: enscript

enscript is a handy program that takes your text files and turns them into PostScript. enscript comes with a wide variety of formatting options. There is a GNU version available, and a few Unixes include a version by default. enscript is particularly useful when your main printer speaks primarily PostScript.

Detailed information on everything enscript can do is available in its manpage, but here are a few examples:

% enscript -G stuff.txt
  Fancy ("Gaudy") headers
% enscript -2r stuff.txt
  Two-up printing -- two pages side-by-side on each page of paper
% enscript -2Gr stuff.txt
  Two-up with fancy headers
% enscript -P otherps stuff.txt
  Print to the otherps printer instead of the default
% enscript -d otherps stuff.txt
  Ditto
% enscript -i 4 stuff.txt
  Indent every line four spaces
% enscript --pretty-print=cpp Object.cc
  Pretty print C++ source code
% enscript -E doit.pl
  Pretty print doit.pl (and automagically figure out that it's Perl from the .pl suffix)

One thing to watch for: enscript's default page size is A4, and in the United States most printers want letter-sized pages. You can set the default page size to letter when installing enscript (many U.S. pre-built binary packages do this for you), or you can use the -M letter or - -media=letter option when you call enscript.

If you want a default set of flags to be passed to enscript, set the ENSCRIPT environment variable. Anything you pass on the command line will override values in ENSCRIPT.

-- DJPH



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.