procmail
[Top] [All Lists]

Re: Help w/splitting

1998-09-13 05:16:45
At 03:52 -0700 13 Sep 1998, Dave Wells <wellsian(_at_)netgate(_dot_)net> wrote:
Can anyone tell me what's wrong with this?  I'm trying to split some old
email archives into individual files while stripping unimportant header
fields.  From my shell I'm trying: 

  % set FILENO=0000

followed by the real work:

  % formail < inputfile -k -X Date: -X From: -X To: -X Subject: -X
  In-Reply-To: -X X-Mailer: +1 -ds > $FILENO.txt

What I end up with is one big file named "0000.txt" instead of a bunch of
little files counting upward from 0000.txt.  My interpretation of the
manpage says it should spit out each message after incrementing FILENO.
Obviously I'm mistaken.

The formail manpage seems to indicate that the messages will just be
rejoined onto stdout if you don't give -s a real program to feed.  So I
also tried using ...-ds cat -e $FILENO.txt with the same results.

In both of these cases, $FILENO is expanded by the shell before formail
is executed, it needs to be quoted to prevent that.  But even just doing
that won't solve the problem, since although formail will set the
variable it doesn't do variable substitution, so the program that it
runs needs to do that.  Here's a simple example:

formail -d < inputfile -s sh -c 'cat > $FILENO.txt'

This uses sh to expand the variable, and run cat to copy the data.

-- 
Aaron Schrab     aaron(_at_)schrab(_dot_)com      http://www.execpc.com/~aarons/
 I'm still waiting for the advent of the computer science groupie.

<Prev in Thread] Current Thread [Next in Thread>