Frequently Asked Question
How do I format text neatly with fold, fmt, and column?
fold wraps long lines to a fixed width. fold -w 80 breaks each line at 80
characters; fold -s -w 80 does the same but breaks at spaces rather than
mid-word. It is mechanical: it counts characters and inserts newlines, with no
understanding of paragraphs. fmt is smarter, it reflows text paragraph by
paragraph, joining short lines and breaking long ones to roughly fit a width
(75 characters by default). It treats blank lines as paragraph boundaries,
which makes it suitable for prose but not for code.
column does something different: it formats tabular input into aligned
columns. Given a tab-separated file, column -t produces a tidy table with
auto-sized columns; column -t -s, does the same for comma-separated input.
Piped through after a cut or awk it turns ragged output into something
readable. Together these three cover most of the layout problems that arise
when piping text to a terminal: fold for raw width, fmt for prose, column
for tables.