Linux Comm Fmt
# Linux fmt Command
[ Linux Command Reference](#)
The Linux `fmt` command is used to format text files.
The `fmt` command reads content from specified files, reformats it according to specified formats, and outputs it to standard output. If the specified filename is "-", the `fmt` command reads data from standard input.
### Syntax
fmt [file...]
**Parameter Description**:
* -c or --crown-margin Indent the first two columns of each paragraph.
* -p or --prefix= Only merge columns containing the specified string, commonly used for comments in programming languages.
* -s or --split-only Only split columns that exceed the column width, but do not merge columns that are shorter than the column width.
* -t or --tagged-paragraph Indent the first two columns of each paragraph, but with different indentation formats for the first and second columns.
* -u or --uniform-spacing Use a single space character between each character, and two space characters between each sentence.
* -w or --width= or - Set the maximum number of characters per column.
* --help Online help.
* --version Display version information.
### Examples
Reformat a specified file. For example, if the file `testfile` contains 5 lines of text, you can use the command to reformat the file. The command is:
fmt testfile
The output result is as follows:
$ fmt testfile #Reformat testfile file hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile! Linux Linux
Reformat the file `testfile` to 85 characters per line and output to standard output. The command should be:
fmt -w 85 testfile
For comparison, first use the `cat` command to view the file contents:
$ cat testfile #View the contents of testfile file hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile! Linux Linux
After reformatting with the `fmt` command, the output result is as follows:
$ fmt -w 85 testfile #Specify reformatting width as 85 characters hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile! Linux Linux
[ Linux Command Reference](#)
YouTip