In this tutorial, I use fmt command to format a file, set the column with, and format uniform spaces. Now, let’s go fmt command in Linux for example.
Table of Contents
What does fmt mean?
fmt – simple optimal text formatter
Syntax
fmt [-WIDTH] [OPTION]... [FILE]...
In man page the describe it
- fmt – simple optimal text formatter.
- man fmt – More details information about fmt command.

fmt command in linux with example
By default, fmt sets the column width at 75.
I have created a file fmt_command.txt
[vagrant@DevopsRoles ~]$ cat fmt_command.txt HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Devops Roles. Hello world. xxx.
fmt with no options
[vagrant@DevopsRoles ~]$ fmt fmt_command.txt
HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Devops Roles.
Hello world. xxx.
How to change the width of formatting.
[vagrant@DevopsRoles ~]$ fmt --width 20 fmt_command.txt HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Devops Roles. Hello world. xxx.
with -u option uses one space between words and two spaces after sentences for formatting.
[vagrant@DevopsRoles ~]$ fmt -u fmt_command.txt HuuPV, My website DevopsRoles.com and HuuPhan.com.SN:199x. Devops Roles. Hello world. xxx.
Conclusion
fmt command is a simple command in Linux. It is used to format a file, set the column with, and format uniform spaces. Thank you for reading the DevopsRoles page!