I had the same problem -- emailing plain text files containing hard line feeds within the body of a paragraph at 80 characters ... and those files look terrible on devices that are (a) doing their own line wrap, and (b) wrapping at a width less than 80 ... that is, the 80-charater splits are clearly visible where the text ends in the middle of line.
How to unwrap those lines?
Use the unix command line tool 'fmt', as suggested by Raúl Salinas-Monteagudo. Change the line length (-w ##) to a useful number. You could try 65 or 55, or, try 1111 or larger.
Example:
This file from the weather office (https://forecast.weather.gov/product.php?site=NWS&issuedby=AT&product=TWO&format=txt&version=1&glossary=0) contains hard line feed embedded within the body of a paragraph. I want line feeds only at end of paragraph. Piping the output to 'fmt -w 1111' (for paragraphs less than 1111 characters in length) takes care of the problem:
/usr/local/bin/w3m -dump 'https://forecast.weather.gov/product.php?site=NWS&issuedby=AT&product=TWO&format=txt&version=1&glossary=0' | sed -n '/TWOAT/,/Forecaster/p' | fmt -w 1111
.
Changes appearance from this:
The National Hurricane Center is issuing advisories on
Tropical Storm Beryl, located a couple of hundred miles
east of the Lesser Antilles, and on Tropical Storm
Chris, located more than one hundred miles south of the
North Carolina Outer Banks.
Tropical cyclone formation is not expected during the
next 5 days.
to this:
The National Hurricane Center is issuing advisories on Tropical Storm Beryl, located a couple of hundred miles east of the Lesser Antilles, and on Tropical Storm Chris, located more than one hundred miles south of the North Carolina Outer Banks.
Tropical cyclone formation is not expected during the next 5 days.
\n`'s when natural break is (and it happens only when new paragraph is created, so there happends to be second newline created). So one
null` would make no new line, twonull
's - two new lines – Szymon Szydełko Jun 22 '13 at 23:20