← 返回命令列表

Linux command

groff 命令

文件

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Format document to PDF

groff -Tpdf [file.ms] > output.pdf

Format with man macros

groff -man [file.1] > output.ps

Format with ms macros to PDF

groff -ms -Tpdf [file.ms] > output.pdf

Preview in terminal

groff -Tutf8 [file.roff] | less

Process with table and equation preprocessors

groff -t -e -ms [file.ms] > output.ps

Format a man page to plain text

groff -Tutf8 -man [file.1]

Display the pipeline without executing it

groff -V -Tpdf [file.ms]

说明

groff is the GNU implementation of the roff document formatting system. It is a front-end that orchestrates the execution of preprocessors, the troff formatter, and an output driver in a pipeline. It processes text files with embedded formatting commands to produce typeset output in various formats including PDF, PostScript, HTML, and terminal display. The system includes preprocessors for tables (tbl), equations (eqn), and diagrams (pic), and supports multiple macro packages for different document types.

参数

-T _DEVICE_
Output device (pdf, ps, html, utf8, ascii, latin1, dvi).
-m _MACRO_
Use macro package (man, ms, me, mm).
-t
Run tbl preprocessor for tables.
-e
Run eqn preprocessor for equations.
-p
Run pic preprocessor for diagrams.
-R
Run refer preprocessor for bibliographic references.
-s
Run soelim preprocessor for file inclusion.
-G
Run grap preprocessor for graphs.
-S
Safer mode. Disables .open, .opena, .pso, .sy, and .pi requests.
-U
Unsafe mode. Reverts to the unsafe requests disabled by -S.
-V
Print the pipeline that would be run to standard error, without executing it.
-Z
Disable postprocessing. Output raw troff intermediate output.
-a
Generate a plain text approximation of the typeset output.
-b
Print a backtrace on each error or warning.
-man
Shorthand for -m man. Use man macros.
-ms
Shorthand for -m ms. Use ms macros.
--help
Display help information.

FAQ

What is the groff command used for?

groff is the GNU implementation of the roff document formatting system. It is a front-end that orchestrates the execution of preprocessors, the troff formatter, and an output driver in a pipeline. It processes text files with embedded formatting commands to produce typeset output in various formats including PDF, PostScript, HTML, and terminal display. The system includes preprocessors for tables (tbl), equations (eqn), and diagrams (pic), and supports multiple macro packages for different document types.

How do I run a basic groff example?

Run `groff -Tpdf [file.ms] > output.pdf` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -T _DEVICE_ do in groff?

Output device (pdf, ps, html, utf8, ascii, latin1, dvi).