From: | Luke Kendall <luke@********.CANON.OZ.AU> |
---|---|
Subject: | Shrinking mail log files |
Date: | Thu, 2 Mar 1995 23:18:00 +1100 |
long way away (i.e., lots and lots of `Received:...' guff in
your mail headers, and you save lots of this mail, then
you might like this short awk script.
You give it a list of (mailbox) files as input, and it strips
out the guff and writes the shorter versions out under the same
filename, but with a `-c' appended to the filename. I've called
it `cmail', for `compress mail'.
For me, it makes my shadowrun mailboxes 30% shorter. They're still
perfectly intelligible to mail, and you can then compress them with
with true compression tools, of course, if you're archiving them.
(It has just saved me about 1.5Mb, before gzip'ing.)
Enjoy, (or not :-),
luke
(Script follows - save it as `cmail', and then: chmod 755 cmail)
#!/bin/sh
#
# Strip off the boring `Received: ...' lines from mail items in a
# Unix mailbox.
#
# Author: Luke Kendall
#
for f
do
echo "$f:"
awk '
BEGIN {
header = 0
}
/^From / {
header = 1
}
/^$/ {
if (header)
header = 0
}
/^[ ]/ {
if (recv)
next
}
{
if (header)
{
recv = ($1 == "Received:")
if (!recv)
}
else
{
}
}
' "$f" > "$f-c"
ls -l "$f" "$f-c"
done