linux命令之fold

1.fold介绍

linux命令fold用于将文本文件中的行进行折叠处理,使其适应特定的显示宽度。

2.fold用法

fold [参数] filename

参数说明
-b指定折行的字节数,而不是列数
-s指定折叠后的每行宽度。默认宽度为80个字符

3.fold样例

3.1.fold版本查看

命令:

fold --version

[root@patrolagent ~]# fold --version
fold (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
[root@patrolagent ~]# 

3.2.fold帮助

命令:

fold --help

[root@patrolagent ~]# fold --help
Usage: fold [OPTION]... [FILE]...
Wrap input lines in each FILE (standard input by default), writing to
standard output.

Mandatory arguments to long options are mandatory for short options too.
  -b, --bytes         count bytes rather than columns
  -c, --characters    count characters rather than columns
  -s, --spaces        break at spaces
  -w, --width=WIDTH   use WIDTH columns instead of 80
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'fold invocation'
[root@patrolagent ~]# 

3.3.指定折叠后的每行宽度

命令:

fold -w 3 1.txt

[root@patrolagent ~]# fold -w 3 1.txt 
aaa
   
bbb
ddd
 cc
c
[root@patrolagent ~]# 

3.4.制定折叠后的每行字节

命令:

fold -b3 1.txt

[root@patrolagent ~]# cat 1.txt 
aaa   bbb
ddd ccc
[root@patrolagent ~]# fold -b3 1.txt 
aaa
   
bbb

dd
d c
cc
[root@patrolagent ~]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值