如何在文件中的固定数目的字符后插入新行字符 [英] How to insert a new line character after a fixed number of characters in a file

查看:88
本文介绍了如何在文件中的固定数目的字符后插入新行字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个bash或sed脚本(preferably一个班轮)有,我可以固定数量巨大的文本文件的字符后插入新行字符。

I am looking for a bash or sed script (preferably a one-liner) with which I can insert a new line character after a fixed number of characters in huge text file.

推荐答案

如何这样的事情?变化20是字符的新行之前的数量,和temp.text是在替换该文件..

How about something like this? Change 20 is the number of characters before the newline, and temp.text is the file to replace in..

sed -e "s/.\{20\}/&\n/g" < temp.txt

这篇关于如何在文件中的固定数目的字符后插入新行字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆