良许Linux教程网 Linux命令大全 Linux常用命令fold命令具体使用方法

Linux常用命令fold命令具体使用方法

Linux常用命令fold命令用于限制文件列宽,fold指令会从指定的文件里读取内容,将超过限定列宽的列加入增列字符后,输出到标准输出设备,下面良许教程网为大家分享一下Linux常用命令fold命令具体使用方法。

Linux常用命令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常用命令fold命令的使用方法分享结束,大家如果对fold命令的使用方法还有问题可以通过评论区将问题提交我们。

以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

img

本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部