[CentOS] Need to split long lines in mail archives

Mon Apr 9 17:38:25 UTC 2012
ken <gebser at mousecar.com>

Sounds like you need to loop through a bunch of files and process each 
separately... so:

$!/bin/bash

cd /path/to/archives/
for $f in $(find . -name *.html)
do
fmt -s $f > $f.out
mv $f.out $f  # rename back to original name
done

Untested.  But this is basically what you want to do.  And it's a good 
sort of structure to pick up on.  You'll use it often.


hth,
ken

On 04/09/2012 01:09 PM James B. Byrne wrote:
> CentOS-6.2
>
> 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.
>
>