On 06/14/2016 10:51 AM, John Poltorak wrote: > I think each msg starts with *Return-Path:* > so I guess I need to insert an extra line at the start of each msg... > > A simple sed script should suffice to convert each msg. Do I just need > to insert '*From *' as the first line of each msg?
Ideally, you insert 'From address date` where address is the address without the <> from the Return-Path: and date is the string produced by the 'date' command. The attached addfrom script is what I use. It's overly complex for your purpose and converts one message in one file in place. You could probably adapt it to your purpose. -- Mark Sapiro <m...@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
#! /bin/bash # # Convert a single saved email with a Return-Path: as its first line # to a mailbox by adding a From_ # if [ ! -w "$1" ]; then echo usage: addfrom file exit fi d=`date` f1=`mktemp` f2=`mktemp` head -1 "$1" > $f1 if grep -q -i -e "^From " $f1 ; then echo File already has From_ line rm $f1 $f2 exit fi if ! grep -q -i -e "^return-path:" $f1 ; then echo "Return-Path: <bo...@example.com>" > $f1 fi sed -e "s/^.*</From /" -e "s/>.*/ $d/" <$f1 >$f2 # strip any trailing <cr>s sed -e 's/\r$//' < "$1" >> $f2 # make sure we have a trailing empty line echo >$f1 cat $f2 $f1 $f1 > "$1" rm $f1 $f2
------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org