Linux uses plain text as the foundation for data representation, logging, configuration, and documentation. To create well-structured output—whether for printing, scripting, or reports—users can rely on formatting utilities designed to control line numbering, wrapping, spacing, and even typesetting.
nl adds line numbers with control over logical page sections and custom numbering formats.
nl distros.txtnl -n rz -w 3 -s ' '\\:\\:\\: (header), \\:\\: (body), \\: (footer)fold wraps long lines to a fixed width, useful for display limitations.
echo "Sample sentence here." | fold -w 12 -sfmt reformats paragraph-style input to a consistent width and spacing, ideal for comments and structured notes.
fmt -w 50 file.txtfmt -p '# ' file.txtpr paginates content with headers, page breaks, and margins.
pr -l 15 -w 65 distros.txtprintf formats values using placeholders and field controls, ideal for scripts and reports.
printf "Line: %05d\t%.2f\t%s\n" 7 3.14 "Done"| Specifier | Usage |
|---|---|
| %d | Decimal integer |
| %f | Floating-point |
| %s | String |
| %x / %X | Hexadecimal |
| %% | Literal percent sign |
groff formats documents with macros, supporting output for screen or print (PostScript, PDF).
zcat man.1.gz | groff -mandoc -T asciigroff -mandoc man.1 > page.ps
ps2pdf page.ps page.pdftbl:groff -t -T ascii formatted-table.txtLinux formatting tools like nl, fold, fmt, pr, printf, and groff help users present structured output professionally. Whether preparing printed documents, structured terminal data, or formatted scripts, these utilities are indispensable for clear communication in the Unix world.