开发者

Shell script to force carriage return to avoid long lines

开发者 https://www.devze.com 2023-01-23 12:04 出处:网络
I hav开发者_StackOverflowe to use a tool (namely, Rez) which processes text but does not allow long text lines; I would like to shorten long lines with a pre-formatting script.

I hav开发者_StackOverflowe to use a tool (namely, Rez) which processes text but does not allow long text lines; I would like to shorten long lines with a pre-formatting script.

The script I'm looking for is a simple (darwin/unix) shell script which cuts long lines, for instance inserting a carriage return after the 70th character of the line, if the character is a space (any other idea would work, I thing).

Any idea how to do that?

Thanks


the fold utility does the job, with the -s option. Do not forget to set the correct locale setting so that fold does not fail on special characters.

All my thanks to mvds.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号