Home  >  Article  >  Operation and Maintenance  >  What does Linux fmt mean?

What does Linux fmt mean?

藏色散人
藏色散人Original
2023-03-27 10:16:451460browse

Linux fmt is a command used to format text files. This command will read the content from the specified file, rearrange it according to the specified format, and output it to the standard output device; if the specified file name If "-", the fmt command will read data from the standard input device.

What does Linux fmt mean?

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

What does Linux fmt mean?

Linux fmt command is used to format text files.

The fmt command will read the content from the specified file, rearrange it according to the specified format, and output it to the standard output device. If the specified file name is "-", the fmt command will read data from the standard input device.

Syntax

fmt [-cstu][-p<列起始字符串>][-w<每列字符数>][--help][--version][文件...]

Parameter description:

-c或--crown-margin 每段前两列缩排。
-p<列起始字符串>或-prefix=<列起始字符串> 仅合并含有指定字符串的列,通常运用在程序语言的注解方面。
-s或--split-only 只拆开字数超出每列字符数的列,但不合并字数不足每列字符数的列。
-t或--tagged-paragraph 每列前两列缩排,但第1列和第2列的缩排格式不同。
-u或--uniform-spacing 每个字符之间都以一个空格字符间隔,每个句子之间则两个空格字符分隔。
-w<每列字符数>或--width=<每列字符数>或-<每列字符数> 设置每列的最大字符数。
--help 在线帮助。
--version 显示版本信息。

Example

Rearrange the specified file. For example, the file testfile has a total of 5 lines of text. You can rearrange the file format through the command:

fmt testfile

The output result is as follows:

$ fmt testfile #重排testfile 文件  
hello Linux! Linux is a free Unix-type operating system. This is a  
Linux testfile! Linux Linux

Rearrange the file testfile into 85 characters. One line, and output it on the standard output device. The command should be:

fmt -w 85 testfile

For comparison, first use the cat command to view the file content:

$ cat testfile #查看testfile 文件的内容  
hello Linux!  
Linux is a free Unix-type operating system.  
This is a Linux testfile!  
Linux  
Linux

After using the fmt command to rearrange, the output results are as follows :

$ fmt -w 85 testfile #指定重排宽度为85个字符  
hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile!  
Linux Linux

Recommended study: "linux video tutorial"

The above is the detailed content of What does Linux fmt mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is linux monoNext article:what is linux mono