[TAG] mbox selective deletion
Ben Okopnik
ben at linuxgazette.net
Wed Feb 17 04:32:11 MSK 2010
On Tue, Feb 16, 2010 at 02:57:30PM -0500, Samuel Bisbee-vonKaufmann wrote:
> On Mon, Feb 15, 2010 at 07:21:47PM -0500, Ben Okopnik wrote:
> > On Fri, Feb 12, 2010 at 11:48:28PM -0500, Samuel Bisbee-vonKaufmann wrote:
> > >
> > > Yeah, coding against "keep everything on one gigantic file" isn't very fun,
> > > though it makes administration a lot easier.
> >
> > But it makes processing a lot slower - and it's an asymptotic curve.
>
> Thanks for re-stating the first half of my point, but with fancier jargon. :-P
Aw, hell, Sam - I figgered after you went to thet there fancy Bawston
collitch, you fergot how to talk lahk folks, so I copied some stuff
outen a book fer ya... great-great-grandpaw got it from a big city
liberry jest so all we'uns could see what one looked lahk. Hit's got
some uh thet fancy talk in it, so I reckoned hit would suit ya.
(By the way, that there 'puter you sent us shore was complicated. I took
hit all apart and couldn't find neether a carbureter nor a pull-cord
nowheres, so I give up on it. Dern it, guess I'll hev to mow the hay by
hand *agin*...)
> Indexes and databases are great, but they'll quickly increase the complexity of
> my program.
[blink] You and I must mean different things by 'database', then.
```
#!/bin/bash
# Created by Ben Okopnik on Tue Feb 16 19:58:51 EST 2010
[ -z "$1" ] && { printf "Usage: ${0##*/} <hdr_name> <hdr_val> [name val] ... ...\n"; exit 1; }
[ "$(($# % 2))" -ne 0 ] && { printf "# of headers != # of values.\n"; exit 1; }
sql='delete from emails where'
while [ "$#" -ne 0 ]
do
sql="$sql $1 = '$2'"
[ "$#" -gt 2 ] && sql="$sql and"
shift; shift
done
echo "$sql"|/usr/bin/mysql -u user dbname
'''
(You did say you wanted to stick with the shell, right?)
This would be the entire deletion program. It would also beat anything
that parsed the file on every pass, speedwise.
> Also, adding dependencies will make it harder to port this
> software; yes, things like [database/caching/index software of choice] is often
> available, but I have dealt with a lot of hosting environments where it's a
> political process to get anything new added.
That's exactly why I mentioned indexing as another option: it requires
no other software. You can generate an index file with Mail::MboxParser,
then specify its name in the 'new' method - and you're done.
> > Wouldn't be a problem. The nuclear-powered mechanical dwarves beneath
> > the surface of this module will do the right thing if you only ask them.
> > :)
>
> Hope they aren't unionized!
They'd miss their ions terribly if that ever happened... :)))
--
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *
More information about the TAG
mailing list