ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Maybe something like sed -r 's/(.{1,320}) (.)/\1\n\n\2/g', but that's for 1-320 characters per line.
Kevin Barry
edit: This might be what you're looking for: sed -r 's/(.{320}[^ ]*) (.)/\1\n\n\2/g'.
Hi,
I think the OP wants to match a literal dot at the end followed by a space.
@OP:
Try also this alternatives:
Code:
sed -r 's/(.{320}[^.]*\.)[[:blank:]]+/\1\n\n/g' file
sed -r 's/(.{320}[^.]*\.)[[:blank:]]*/\1\n\n/g' file
I think you want the latter. It will split at the next dot even if it is not followed by a space.
The first one will only split if the dot is followed by at least one space or more. Both will remove all spaces following the dot.
However. When struggling towards perfectness I met my limits again.
How can I make this linebreak happen if the script finds any of listed letters or any combination of them, actually any [^A-Za-z], followed by space. Especially
However. When struggling towards perfectness I met my limits again.
How can I make this linebreak happen if the script finds any of listed letters or any combination of them, actually any [^A-Za-z], followed by space. Especially
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.