Reformat paragraphs

The fmt command in Linux is used to reformat paragraphs in a text file. It is useful in situations when you have a file with long or irregular line lengths. The fmt command helps you clean up the file by producing the balanced output with lines similar in length. If not specified otherwise, fmt will create text to a width of 75 characters wide.

Here is an example text:

fmt example

Notice how the lines are of different lengths. We can use the fmt command to reformat the paragraphs:

fmt command example

You can change the width with the -w option:

fmt command change width

Geek University 2022