Linux fold命令

更新时间: 2019-10-16 12:40

Linux fold命令用于限制文件列宽。

fold指令会从指定的文件里读取内容,将超过限定列宽的列加入增列字符后,输出到标准输出设备。若不指定任何文件名称,或是所给予的文件名为"-",则fold指令会从标准输入设备读取数据。

语法

fold [-bs][-w<每列行数>][--help][--version][文件...]

参数

  • -b或--bytes 以Byte为单位计算列宽,而非采用行数编号为单位。
  • -s或--spaces 以空格字符作为换列点。
  • -w<每列行数>或--width<每列行数> 设置每列的最大行数。
  • --help 在线帮助。
  • --version 显示版本信息。

实例

将一个名为testfile 的文件的行折叠成宽度为30,可使用如下命令:

fold -w 30 testfile

为了对比,先将testfile文件输出如下:

$ cat testfile #查看testfile 中的内容  
Linux networks are becoming more and more common, but 
security is often an overlooked  
issue. Unfortunately, in today’s environment all networks 
are potential hacker targets,  
from top-secret military research networks to small home LANs.  
Linux Network Security focuses on securing Linux in a 
networked environment, where the  
security of the entire network needs to be considered 
rather than just isolated machines.  
It uses a mix of theory and practical techniques to 
teach administrators how to install and  
use security applications, as well as how the 
applications work and why they are necessary. 

然后使用fold命令折叠显示:

$ fold -w 30 testfile #行折叠成宽度为30,显示testfile 文件  
Linux networks are becoming mo  
re and more common, but securi  
ty is often an overlooked issu  
e. Unfortunately, in today’s  
environment all networks are  
potential hacker targets, from  
top-secret military research  
networks to small home LANs.  
Linux Network Security focuses  
on securing Linux in a networ  
ked environment, where the sec  
urity of the entire network ne  
eds to be considered rather th  
an just isolated machines. It  
uses a mix of theory and pract  
ical techniques to teach admin  
istrators how to install and u  
se security applications, as w  
ell as how the applications wo  
rk and why they are necessary 
51单片机应用从零开始

51单片机应用从零开始

杨欣、王玉凤、刘湘黔 / 清华大学 / 2008-1 / 39.80元

《51单片机应用与实践丛书•51单片机应用从零开始》在分析初学者认知规律的基础上,结合国内重点大学一线教师的教学经验以及借鉴国外经典教材的写作手法,对51单片机的应用基础知识进行系统而翔实的介绍。读者学习每一章之后,"实例点拨"环节除了可以巩固所学的内容外,还开辟了单片机应用的视野;再加上"器件介绍"环节,又充实了对单片机从基础到应用所需要的知识。8051单片机不仅是国内用得最多的单片机之一,同时......一起来看看 《51单片机应用从零开始》 这本书的介绍吧!

HTML 压缩/解压工具

HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB HSV 转换

RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具

HEX CMYK 转换工具

HEX CMYK 互转工具