#!/usr/bin/awk -f # Written by ben at inwa dot net. Released into the public domain. # # This script will parse an mbox, replacing the first subject line # of each message with the last subject line in that message. It's # intended to make the Qmail alias mbox show something other than # "failure notice" on every single message. /^From / { sub("\nSubject: [^\n]*\n","\n"subject"\n",message) print message subject = 0 message = $0 } /^Subject: / { subject = $0 } { message = message $0 "\n" }