procmail
[Top] [All Lists]

Re: reverse the order of messages in a mailbox?

1999-10-14 04:37:46
On Wed, 13 Oct 1999 23:46:32 -0400, Stan Ryckman
<stanr(_at_)sunspot(_dot_)tiac(_dot_)net> wrote:
At 10:32 AM 10/13/99 -0500, David W. Tamkin wrote:
#!/bin/sh
FILENO=-01000000 formail -s \
procmail -p DEFAULT=${PWD-`pwd`}/'$FILENO' /dev/null # from stdin
cat ./-* && rm -r ./-* # to stdout
(why -r?)
This will probably run into difficulty long before a million
messages, probably on a plausible though hefty number, when the
filename expansions of ./-* exceed the shell's command arguments
length limit.
One could replace the last line with something (untested) like:
  ls -1 | egrep '^-' | tee /tmp/$$ | xargs cat && \
    touch ./-- && cat /tmp/$$ | xargs rm -f ./-- && rm /tmp/$$

If you're in this deep a mess, why not just

  ls -1 | sed -n '/^-/s%.*%cat ./& ; rm -f ./&%p' | sh

... or simply pipe to xargs /tmp/script-which-does-both-cat-and-rm

/* era */

.obPlug: <http://www.iki.fi/era/unix/arg-max.html>

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition