Formatting with fmt

After you’ve been typing away—writing the Great American Novel, perhaps—you might notice that you’re suffering from creeping margin uglies, like those shown in Code Listing 6.21. Never fear, fmt can help. Just run your text through fmt, and all will be well.

To Format with fmt:

  • fmt spiderstory.unformatted

    At the shell prompt, just tell fmt to do its thing, and you’ll be in business.

✓ Tip

  • You can supplement fmt with handy flags to help make lines more readable. For example, you can often use fmt –u to make spacing uniform: one space between words, and two spaces between sentences. Or, try fmt –w to specify the width of the formatted text; for example, –w 60 would specify a 60-character-wide line.

Code Listing 6.21. With ...

Get Unix Third Edition: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.