简体   繁体   English

如何通过计算字符来拆分文本文件并找到 30 到 40 个字符之间的空格(不分隔单词)

[英]How can I split text files by counting characters and find space (without dividing words ) between 30 and 40 characters

This command splits text file by 30 characters.此命令将文本文件分割为 30 个字符。 It also divide words but I need help for split text without divide the word find space between 30 and 40 after that split text file.它也划分了单词,但我需要拆分文本的帮助,而不需要在拆分文本文件之后在 30 到 40 之间划分单词查找空间。

sed -e 's/.\{30\}/&\n/g' filename

Better use a proper lib, like in .最好使用适当的库,例如 The name for this is text wraping :它的名称是文本换行

perl -MText::Wrap -lne '
    $Text::Wrap::columns = 30;
    print wrap("", "", $_)
' file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM