在换行符上拆分80个字符

时间:2018-11-12 17:24:46

标签: bash

我在txt文件中有长文本

  @Column(name = "create_date", nullable = false, updatable = false)
    private Instant createDate;

如何将80个字符后的文本拆分为新行?

example:
https://pastebin.com/MnbR0Vdh

it should look like that:
https://pastebin.com/ASKHKrS6

1 个答案:

答案 0 :(得分:1)

fold file

sed 's/.\{80\}/&\n/g' file

您说您想以80个字符包装文本,但是示例输出显示不同,也许您正在寻找这样的东西?

sed 's/\(^\.\.\. \)\?.\{75\}/&\n... /g' file