[英]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.