[CentOS] Need to split long lines in mail archives

Mon Apr 9 17:09:59 UTC 2012
James B. Byrne <byrnejb at harte-lyne.ca>


I am investigating how to split long lines present in a
Mailman generated html archives.  Mailman places the email
bodies within <pre></pre> tags and some users have MUAs
that send entire paragraphs as one long line.

I have looked at fmt and fold but these assume a pipeline
from stdout to a fixed filename, which presumably is best
done at the time of the original file's creation.  I am
looking for a way to deal with multiple existing files in
a batch fashion so that the reformatted file is written
back out to the same file name oin the same location.

I cannot seem to hit upon a way to get this to work using
find, xargs and fmt (or fold).  Nor can I seem to find an
example of how this might be done using these utilities.

What I would like to discover is the functional equivalent
of this:

find /path/to/archives/*.html -print | xargs -I {} fmt -s
{} > {}

This syntax does not work of course because the xargs file
name substitution only occurs once in the initial argument
list of the following command. But, this example does
describe the effect I wish to obtain, to have the original
file name receive the reformatted contents.

***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3