01.12.2012 Views

by Trent A. Fisher and Werner Lemberg - The GNU Operating System

by Trent A. Fisher and Werner Lemberg - The GNU Operating System

by Trent A. Fisher and Werner Lemberg - The GNU Operating System

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2: Invoking groff 15<br />

2.6 Invocation Examples<br />

This section lists several common uses of groff <strong>and</strong> the corresponding comm<strong>and</strong><br />

lines.<br />

groff file<br />

This comm<strong>and</strong> processes ‘file’ without a macro package or a preprocessor.<br />

<strong>The</strong> output device is the default, ‘ps’, <strong>and</strong> the output is sent to stdout.<br />

groff -t -m<strong>and</strong>oc -Tascii file | less<br />

This is basically what a call to the man program does. gtroff processes the<br />

manual page ‘file’ with the ‘m<strong>and</strong>oc’ macro file (which in turn either calls<br />

the ‘man’ or the ‘mdoc’ macro package), using the tbl preprocessor <strong>and</strong> the<br />

ASCII output device. Finally, the less pager displays the result.<br />

groff -X -m me file<br />

Preview ‘file’ with gxditview, using the ‘me’ macro package. Since no ‘-T’<br />

option is specified, use the default device (‘ps’). Note that you can either say<br />

‘-m me’ or ‘-me’; the latter is an anachronism from the early days of UNIX. 1<br />

groff -man -rD1 -z file<br />

Check ‘file’ with the ‘man’ macro package, forcing double-sided printing –<br />

don’t produce any output.<br />

2.6.1 grog<br />

grog reads files, guesses which of the groff preprocessors <strong>and</strong>/or macro<br />

packages are required for formatting them, <strong>and</strong> prints the groff comm<strong>and</strong><br />

including those options on the st<strong>and</strong>ard output. It generates one or more<br />

of the options ‘-e’, ‘-man’, ‘-me’, ‘-mm’, ‘-mom’, ‘-ms’, ‘-mdoc’, ‘-mdoc-old’,<br />

‘-p’, ‘-R’, ‘-g’, ‘-G’, ‘-s’, <strong>and</strong> ‘-t’.<br />

A special file name ‘-’ refers to the st<strong>and</strong>ard input. Specifying no files<br />

also means to read the st<strong>and</strong>ard input. Any specified options are included<br />

in the printed comm<strong>and</strong>. No space is allowed between options <strong>and</strong> their<br />

arguments. <strong>The</strong> only options recognized are ‘-C’ (which is also passed on)<br />

to enable compatibility mode, <strong>and</strong> ‘-v’ to print the version number <strong>and</strong> exit.<br />

For example,<br />

grog -Tdvi paper.ms<br />

guesses the appropriate comm<strong>and</strong> to print ‘paper.ms’ <strong>and</strong> then prints it to<br />

the comm<strong>and</strong> line after adding the ‘-Tdvi’ option. For direct execution,<br />

enclose the call to grog in backquotes at the UNIX shell prompt:<br />

‘grog -Tdvi paper.ms‘ > paper.dvi<br />

As seen in the example, it is still necessary to redirect the output to something<br />

meaningful (i.e. either a file or a pager program like less).<br />

1 <strong>The</strong> same is true for the other main macro packages that come with groff: ‘man’,<br />

‘mdoc’, ‘ms’, ‘mm’, <strong>and</strong> ‘m<strong>and</strong>oc’. This won’t work in general; for example, to load<br />

‘trace.tmac’, either ‘-mtrace’ or ‘-m trace’ must be used.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!