Linux fmt command: simple optimization of text formatting
Linux fmt command Function Description
Use the fmt command to reformat each paragraph in the file for output to standard output.
Linux fmt command Syntax
fmt [Option] [File]
The meaning of each option in the command is shown in the table.:
Option | Description |
---|---|
-u | Keep one space between each two words and two spaces after each sentence |
-s | Splitting too long rows, but not automatically completing them |
-w<width> |
Set the maximum row width, the default is 75 columns |
-p<string> |
Reformat only the lines that begin with the specified string, reattaching the prefix to the reformatted line |
-c | Keep the first two lines indented |
-t | Indent the first line to make it different from the second line |
Linux fmt command Demo
Reformat each paragraph in the /root/apidemos.com.txt file
[root@rhel ~]# fmt /root/apidemos.com.txt
Output: