[SOLVED] Out of control mailbox
Joe
lists at joefleming.net
Fri Jul 24 10:46:58 MST 2009
I don't have a choice, it's a remotely hosted server, not mine.
This was the final solution I went with...
# get the total line count, as a number
lines=`wc -l MBOX_FILE | cut -d\ -f2`
# calculate the number of lines to the end of the file
let newlines=${lines}-DESIRED_START_LINE
# let me know what the end result will be
echo -e "old file: ${lines} lines\nnew file: ${newlines} lines"
# create the new file
tail -n $newlines MBOX_FILE > NEW_MBOX_FILE
# finally, replace the old mboxfile
mv MBOX_FILE MBOX_FILE.old && mv NEW_MBOX_FILE MBOX_FILE
I ran that in one string with semicolons. I posted it here commented for
easy reading. Thanks for the help all!
-Joe
kitepilot at kitepilot.com wrote:
> There is a perl script that will turn a mbox file to Maildir.
> Then you can manipulate the messages individually and cat them back together
> after you are done.
> I think...
>
> Man, why are you still "mbox(ing)" ? :)
> ET
>
>
> Joe writes:
>
>> Hey all,
>>
>> I have a user with a huge mailbox that is borking things up here. I was
>> going to drop all mail older than the 19th to reduce the filesize. I had
>> planned to do this by opening it in vim, finding the first line with
>> "Jul 18" and remove from the line before it to line 0. Problem is, it's
>> a 160+ MB file and vim doesn't handle that too well. I know which line
>> number I want to delete to though. So here's the question....
>>
>> How can I remove from line 0 to line 1000000 (as an example) from the
>> file? Or, how can I export from line 1000001 to the end in a new file
>> (which I could then replace the current mailbox file with)? I have no
>> idea how to accomplish either.
>>
>> Thanks in advance for any help!
>>
>> -Joe
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
More information about the PLUG-discuss
mailing list