HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

fmt — Reformat a text file by joining its paragraphs and limiting the line width to a number of characters

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandtextjoiningitsclifilereformatfmt

Problem

How to use the fmt command: Reformat a text file by joining its paragraphs and limiting the line width to a number of characters (75 by default). More information: <https://www.gnu.org/software/coreutils/manual/html_node/fmt-invocation.html>.

Solution

fmt — Reformat a text file by joining its paragraphs and limiting the line width to a number of characters (75 by default). More information: <https://www.gnu.org/software/coreutils/manual/html_node/fmt-invocation.html>.

Reformat a file:
fmt {{path/to/file}}


Reformat a file producing output lines of (at most) n characters:
fmt {{[-w|--width]}} {{n}} {{path/to/file}}


Reformat a file without joining lines shorter than the given width together:
fmt {{[-s|--split-only]}} {{path/to/file}}


Reformat a file with uniform spacing (1 space between words and 2 spaces between paragraphs):
fmt {{[-u|--uniform-spacing]}} {{path/to/file}}

Code Snippets

Reformat a file

fmt {{path/to/file}}

Reformat a file producing output lines of (at most) `n` characters

fmt {{[-w|--width]}} {{n}} {{path/to/file}}

Reformat a file without joining lines shorter than the given width together

fmt {{[-s|--split-only]}} {{path/to/file}}

Reformat a file with uniform spacing (1 space between words and 2 spaces between paragraphs)

fmt {{[-u|--uniform-spacing]}} {{path/to/file}}

Context

tldr-pages: common/fmt

Revisions (0)

No revisions yet.