nroff
Quick Reference
Command Name:
nroff
Category:
text processing
Platform:
linux
Basic Usage:
Common Use Cases
- 1
Document formatting
Create formatted documents using the nroff typesetting system
- 2
Report generation
Generate professional-quality reports and documents
- 3
Scripting
Use in shell scripts to generate formatted documents programmatically
- 4
Document processing
Manipulate and transform document data
Syntax
nroff [OPTION]... [FILE]...
Options
| Option | Description |
|---|---|
| -e | Preprocess with eqn (for mathematical formulas) |
| -h | Use output tabs instead of spaces |
| -i | Read standard input after processing all files |
| -m PACKAGE | Use macro package PACKAGE (e.g., -man, -ms, -mm) |
| -n N | Number first page N |
| -o LIST | Output only pages in LIST |
| -p | Preprocess with pic (for diagrams) |
| -r REG=VAL | Set register REG to VAL |
| -s | Preprocess with soelim (for file inclusion) |
| -t | Preprocess with tbl (for tables) |
| -T NAME | Prepare output for device NAME |
| -U | Unsafe mode (enable potentially dangerous operations) |
| -V | Print version information |
| -w | Enable warning messages |
| -W LEVEL | Set warning level to LEVEL |
| -Z | Suppress formatted output (useful for checking syntax) |
Examples
How to Use These Examples
The examples below show common ways to use the nroff command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
nroff -man man_page.1
Format a man page for terminal display. This is the traditional way to format manual pages for viewing directly in a terminal window.
nroff -ms document.ms > document.txt
Format a document written with ms macros and save the output to a text file. The ms macro package is designed for general document formatting.
man ls | col -b > ls.txt
Capture a formatted man page to a text file. This command pipes the man page through col to remove backspace characters and other formatting artifacts.
nroff -t -e -man manpage.1 | less
Format a man page with table and equation processing and view with less. The -t and -e options enable the tbl (table) and eqn (equation) preprocessors.
Advanced Examples:
nroff -ms -rW60 document.ms
Format a document with a specific line width of 60 characters. The -rW60 option sets the line width register to 60 characters for a narrower output.
nroff -t -pet -ms technical_doc.ms | less
Process a technical document with tables, equations, and diagrams for terminal display. This combines multiple preprocessors (tbl, pic, eqn) for handling complex document elements.