linux 文本文件行读_如何在Linux上的文本文件中换行?

在Linux上处理包含长行的文本文件时,可以使用`fold`命令来实现每行不超过80个字符的折行。该命令提供多种选项,如按字节、字符计数或在空格处分割行。例如,使用`fold -w 80 filename.txt`可将`filename.txt`中的行限制为80个字符宽。
摘要由CSDN通过智能技术生成

linux 文本文件行读

I have some text files which contain some long lines. Now I would like to break lines to at most 80 characters. How to wrap long lines in a text file on Linux?

我有一些文本文件 ,其中包含一些长行。 现在,我想将行最多中断80个字符。 如何在Linux上的文本文件中换行?

The fold command can wrap lines.

fold 命令可以换行。

fold – wrap each input line to fit in specified width

折叠–包裹每条输入线以适合指定的宽度

For your purpose,

为了您的目的

fold -w 80 -c in.txt > out.txt

fold has more options, you may check

折叠有更多选择,您可以检查

-b, –bytes
count bytes rather than columns

-b,-bytes
计算字节数而不是列数

-c, –characters
count characters rather than columns

-c,–字符
计算字符而不是列

-s, –spaces
break at spaces

-s,–空格
打破空间

-w, –width=WIDTH
use WIDTH columns instead of 80

-w,–width = WIDTH
使用WIDTH列而不是80

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自: https://www.systutorials.com/how-to-wrap-long-lines-in-a-text-file-on-linux/

linux 文本文件行读

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值