![](/img/trans.png)
[英]How to split a text file into blocks with 10+ characters without dividing words using sed in Linux?
[英]How can I split text files by counting characters and find space (without dividing words ) between 30 and 40 characters
此命令将文本文件分割为 30 个字符。 它也划分了单词,但我需要拆分文本的帮助,而不需要在拆分文本文件之后在 30 到 40 之间划分单词查找空间。
sed -e 's/.\{30\}/&\n/g' filename
最好使用适当的库,例如perl 。 它的名称是文本换行:
perl -MText::Wrap -lne '
$Text::Wrap::columns = 30;
print wrap("", "", $_)
' file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.