Linux fold命令

Linux 教程 · 2019-02-14 13:29:18

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 

点击查看所有 Linux 教程 文章: https://www.codercto.com/courses/l/14.html

查看所有标签

机器学习

机器学习

(美)Tom Mitchell / 曾华军、张银奎、等 / 机械工业出版社 / 2008-3 / 35.00元

《机器学习》展示了机器学习中核心的算法和理论,并阐明了算法的运行过程。《机器学习》综合了许多的研究成果,例如统计学、人工智能、哲学、信息论、生物学、认知科学、计算复杂性和控制论等,并以此来理解问题的背景、算法和其中的隐含假定。《机器学习》可作为计算机专业 本科生、研究生教材,也可作为相关领域研究人员、教师的参考书。一起来看看 《机器学习》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换