Linux fmt命令使用详解
fmt命令 读取文件的内容,根据选项的设置对文件格式进行简单的优化处理,并将结果送到标准输出设备。
语法
1 | fmt(选项)(参数) |
选项
1 | -c或--crown-margin:每段前两列缩排; |
参数
指定要优化格式的文件。
实例
重排指定文件。如文件testfile共5
行文字,可以通过命令对该文件格式进行重排,其命令为:
fmt testfile
输出结果如下:
$ fmt testfile #重排testfile 文件
hello Linux! Linux is a free Unix-type operating system. This is a
Linux testfile! Linux Linux
将文件testfile重新排成85
个字符一行,并在标准输出设备上输出,其命令应该为:
fmt -w 85 testfile
为了对比,先使用cat 命令查看文件内容:
$ cat testfile #查看testfile 文件的内容
hello Linux!
Linux is a free Unix-type operating system.
This is a Linux testfile!
Linux
Linux
使用fmt命令重排之后,输出结果如下:
$ fmt -w 85 testfile #指定重排宽度为85个字符
hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile!
Linux Linux