
Linux系统中的fmt命令主要用于文本内容的格式调整。
该命令会从给定的文件中读取内容,按照指定的格式重新整理后输出到标准输出。如果提供的文件名是"-",则表示从标准输入获取数据进行处理。
<pre class="brush:php;toolbar:false;">fmt [-cstu][-p][-w][--help][--version][文件...]
参数说明:
对testfile文件进行格式重排操作。假设该文件包含5行内容,可以执行以下命令:
<pre class="brush:php;toolbar:false;">fmt testfile
输出效果如下:
<pre class="brush:php;toolbar:false;">$ fmt testfile #对testfile 文件进行重排 hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile! Linux Linux
若希望将testfile文件按每行最多85字符进行重排,并显示在终端上,可使用:
<pre class="brush:php;toolbar:false;">fmt -w 85 testfile
首先查看原文件内容:
<pre class="brush:php;toolbar:false;">$ cat testfile #查看testfile 文件的内容 hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile! Linux Linux
执行格式化后结果为:
<pre class="brush:php;toolbar:false;">$ fmt -w 85 testfile #设置每行最大宽度为85字符 hello Linux! Linux is a free Unix-type operating system. This is a Linux testfile! Linux Linux
以上就是linux简单文本格式化是什么-fmt命令使用与实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号