Re: How to count new emails in mbox format mailbox?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On Sunday, January 3 at 04:39 PM, quoth Ionel Mugurel Ciobica: You were told already... privmailnew=$(grep -c '^From ' ${private}) inmailnew=$(grep -c '^From ' ${inbox}) That's only true if and only if the mbox file is NOT in mboxcl2 format. Many mbox formats (mboxo, mboxrd, and mutt's favorite: mboxcl) transform internal lines that begin with From into From, but mboxcl2 does not (it uses Content-Length: headers to reliably determine where the next message is). There's a good description of several of the common mbox formats here: http://homepages.tesco.net/J.deBoynePollard/FGA/mail-mbox-formats.html ~Kyle - -- Important families are like potatoes. The best parts are underground. -- Francis Bacon -BEGIN PGP SIGNATURE- Comment: Thank you for using encryption! iQIcBAEBCAAGBQJLQhbGAAoJECuveozR/AWerQAP/R+gajViBpTaPTREIPQCrwjP szvTOmzKaKBkBmqJVk7etzdMRyAtre+Kzupwc8gHO370Saf0beee8e3MWA4hKXPB EFhSDlrUTFquf0EvZe2kUfXgr2V2VeBpujX2lcXMY7rNDS8Z7jw67tgCKg+PYLp4 GkvgqDiSwH/WQrW81IPhRC86z3kBPsQqUuO2ghe+zQNl0i9tOpVF/3ygrEjYTkio 7IuXfTOF+mBpoEBH019TNMjVZxE5OBfT01X0curwEVimRgWUlU0DlXfW7YqrIUVY AhfxH2SptkMZ+ttSmpzIcp2TI5FgpVFOOUu/sgov7iDjite+lgGYlIJWaDVBA20v 30DewWZXZ3WdDuiMWlRBIGgKnpqWNnx2weTAvkxtBp0SKb/8x9hm8uBPCHTSNvqZ 5XjJAUAsGvK4EzEWUKy2ni0KyVNkPgNOjcMTT8KYr8I5vPTfVKdLjTZ3zwDOrDlo 2g3NRoGkv7JgtNv+je45tXygO7nXAQ4ykAkID4/+Tj64Vk61WOx9Sn4fv5Wk0Kuk JJXEvFwdxnYsVe5keugBVJDZlcz2oszMyi3p/Iqxrg22M4M7VojW1i8WMZ0ze0sv s6PFEQfI2DGKF3/I5aoJYF97WLA//uJVT2OXEYrlPFRX1Blep1M6ar/xLYQVYqIf CxlRmlDmsPQ7DRqyKIyU =oLzI -END PGP SIGNATURE-
Re: How to count new emails in mbox format mailbox?
On 26-12-2009, at 18h 12'03, Wu, Yue wrote about Re: How to count new emails in mbox format mailbox? My script does this: count the mails in some particular maildir, then assign the number to a var: if [ -d ${mymaildir} -a $(find ${mymaildir} -type f -print | wc -l) -ne 0 ]; then mailsnew=$(find ${mymaildir}/*/new -type f | wc -l | sed 's/ //g') # mails=$(($(find ${mymaildir}/*/cur -type f | wc -l | sed 's/ //g') + ${mailsnew})) if [ ${mailsnew} -ne 0 ]; then if [ -d ${mymaildir}/private ]; then privmailnew=$(find ${mymaildir}/private/new -type f | wc -l | sed 's/ //g')/ fi if [ -d ${mymaildir}/inbox ]; then inmailnew=$(find ${mymaildir}/inbox/new -type f | wc -l | sed 's/ //g')/ fi mailsfmt=[${privmailnew}${inmailnew}${mailsnew}] fi fi But I don't know how to transform this script to suit for mbox mails counting. You were told already... privmailnew=$(grep -c '^From ' ${private}) inmailnew=$(grep -c '^From ' ${inbox}) Replace ${private} and ${inbox} with the files you keep the e-mails. Ionel
Re: How to count new emails in mbox format mailbox?
* Cameron Simpson on Saturday, January 02, 2010 at 10:34:52 +1100 On 25Dec2009 16:24, Christian Ebert blacktr...@gmx.net wrote: | * Christian Ebert on Friday, December 25, 2009 at 16:22:34 + | Ah, you just want to remove empty mailboxes, then perhaps just | | save_empty=no | | is enough? | | Otherwise something like: | | # delete all empty file inside $mailhier | find $mailhier -type f -size 0 -exec rm -f {} \; | | That's on the command line, in a script you have to escape {}: No. You do not. { and } are not punctuation. (Versus ( for example, which is.) Right. Have you even tested this assertion? I could swear I did, which is why I did it like this in my shell scripts ... but I take everything back ... How about: find $mailhier -type f -size 0 -delete ;-) c -- \black\trash movie_C O W B O Y_ _C A N O E_ _C O M A_ Ein deutscher Western/A German Western --- http://www.blacktrash.org/underdogma/ccc.php
Re: How to count new emails in mbox format mailbox?
Hi Christian! On Sa, 02 Jan 2010, Christian Ebert wrote: How about: find $mailhier -type f -size 0 -delete I believe -delete is not portable regards, Christian -- hundred-and-one symptoms of being an internet addict: 46. Your wife makes a new rule: The computer cannot come to bed.
Re: How to count new emails in mbox format mailbox?
On 25Dec2009 16:24, Christian Ebert blacktr...@gmx.net wrote: | * Christian Ebert on Friday, December 25, 2009 at 16:22:34 + | Ah, you just want to remove empty mailboxes, then perhaps just | | save_empty=no | | is enough? | | Otherwise something like: | | # delete all empty file inside $mailhier | find $mailhier -type f -size 0 -exec rm -f {} \; | | That's on the command line, in a script you have to escape {}: No. You do not. { and } are not punctuation. (Versus ( for example, which is.) Have you even tested this assertion? -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ Would you remember a one-line .sig? - Paul Thompson, thomp...@apple.com
Re: How to count new emails in mbox format mailbox?
grep ^From | wc -l
Re: How to count new emails in mbox format mailbox?
* Wu, Yue on Friday, December 25, 2009 at 13:50:41 +0800 Now I've changed to mbox from maildir, when with maildir, I use a sh script to count the number of mails in directory new/ of each of my mails/ sub-directory, but now I don't know how to achieve it with mbox, any hint will be appreciated. egrep '^From [-a-za-z0-9@[a-za-z0-9]+\.[a-za-z0-9]+ [A-Z][a-z]{2} [A-Z][a-z]{2} [ 1-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{4}$' mbox | wc -l c -- \black\trash movie_C O W B O Y_ _C A N O E_ _C O M A_ Ein deutscher Western/A German Western --- http://www.blacktrash.org/underdogma/ccc.php
Re: How to count new emails in mbox format mailbox?
* Jussi Peltola on Friday, December 25, 2009 at 13:24:03 +0200 grep ^From | wc -l will also catch From: headers. c -- Was heißt hier Dogma, ich bin Underdogma! [ What the hell do you mean dogma, I am underdogma. ] _F R E E_ _V I D E O S_ --- http://www.blacktrash.org/underdogma/
Re: How to count new emails in mbox format mailbox?
* Christian Ebert on Friday, December 25, 2009 at 11:45:34 + * Wu, Yue on Friday, December 25, 2009 at 13:50:41 +0800 Now I've changed to mbox from maildir, when with maildir, I use a sh script to count the number of mails in directory new/ of each of my mails/ sub-directory, but now I don't know how to achieve it with mbox, any hint will be appreciated. egrep '^From [-a-za-z0-9@[a-za-z0-9]+\.[a-za-z0-9]+ [A-Z][a-z]{2} [A-Z][a-z]{2} [ 1-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{4}$' mbox | wc -l oops, should be: egrep '^From [-a-za-z0-9@[-a-za-z0-9]+\.[a-za-z0-9]+ [A-Z][a-z]{2} [A-Z][a-z]{2} [ 1-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{4}$' mbox | wc -l But you might be fine with: grep '^From ' mbox | wc -l c -- \black\trash movie_C O W B O Y_ _C A N O E_ _C O M A_ Ein deutscher Western/A German Western --- http://www.blacktrash.org/underdogma/ccc.php
Re: How to count new emails in mbox format mailbox?
On Fri, Dec 25, 2009 at 11:56:44AM +, Christian Ebert wrote: * Christian Ebert on Friday, December 25, 2009 at 11:45:34 + * Wu, Yue on Friday, December 25, 2009 at 13:50:41 +0800 Now I've changed to mbox from maildir, when with maildir, I use a sh script to count the number of mails in directory new/ of each of my mails/ sub-directory, but now I don't know how to achieve it with mbox, any hint will be appreciated. egrep '^From [-a-za-z0-9@[a-za-z0-9]+\.[a-za-z0-9]+ [A-Z][a-z]{2} [A-Z][a-z]{2} [ 1-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{4}$' mbox | wc -l oops, should be: egrep '^From [-a-za-z0-9@[-a-za-z0-9]+\.[a-za-z0-9]+ [A-Z][a-z]{2} [A-Z][a-z]{2} [ 1-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{4}$' mbox | wc -l But you might be fine with: grep '^From ' mbox | wc -l Thanks, but that's the one part that I want to solve... I'm not familiar with sh script, the script I use for maildir is the follows: mailhier=~/.mutt/mails if [ $(find $mailhier -type f -print | wc -l) -ne 0 ]; then for d in $mailhier/* do if [ $(find $d -type f -print | wc -l) -eq 0 ]; then rm -r $d fi done fi I don't know how to do the same thing in sh script for mbox? Any one can figure me out of it? Thank you. -- Hi, Wu, Yue
Re: How to count new emails in mbox format mailbox?
* Wu, Yue on Friday, December 25, 2009 at 21:12:52 +0800 On Fri, Dec 25, 2009 at 11:56:44AM +, Christian Ebert wrote: egrep '^From [-a-za-z0-9@[-a-za-z0-9]+\.[a-za-z0-9]+ [A-Z][a-z]{2} [A-Z][a-z]{2} [ 1-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [0-9]{4}$' mbox | wc -l But you might be fine with: grep '^From ' mbox | wc -l Thanks, but that's the one part that I want to solve... I'm not familiar with sh script, the script I use for maildir is the follows: mailhier=~/.mutt/mails if [ $(find $mailhier -type f -print | wc -l) -ne 0 ]; then for d in $mailhier/* do if [ $(find $d -type f -print | wc -l) -eq 0 ]; then rm -r $d fi done fi I don't know how to do the same thing in sh script for mbox? Any one can figure me out of it? Ah, you just want to remove empty mailboxes, then perhaps just save_empty=no is enough? Otherwise something like: # delete all empty file inside $mailhier find $mailhier -type f -size 0 -exec rm -f {} \; c -- Was heißt hier Dogma, ich bin Underdogma! [ What the hell do you mean dogma, I am underdogma. ] _F R E E_ _V I D E O S_ --- http://www.blacktrash.org/underdogma/
Re: How to count new emails in mbox format mailbox?
* Christian Ebert on Friday, December 25, 2009 at 16:22:34 + Ah, you just want to remove empty mailboxes, then perhaps just save_empty=no is enough? Otherwise something like: # delete all empty file inside $mailhier find $mailhier -type f -size 0 -exec rm -f {} \; That's on the command line, in a script you have to escape {}: find $mailhier -type f -size 0 -exec rm -f \{} \; c -- \black\trash movie_C O W B O Y_ _C A N O E_ _C O M A_ Ein deutscher Western/A German Western --- http://www.blacktrash.org/underdogma/ccc.php
Re: How to count new emails in mbox format mailbox?
Hello, Am 2009-12-25 13:24:03, schrieb Jussi Peltola: grep ^From | wc -l You mean: grep --regexp=^From |wc-l Thanks, Greetings and nice Day/Evening Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ # Debian GNU/Linux Consultant # http://www.tamay-dogan.net/ Michelle Konzack http://www.can4linux.org/ Apt. 917 http://www.flexray4linux.org/ 50, rue de Soultz Jabber linux4miche...@jabber.ccc.de 67100 Strabourg/France IRC#Debian (irc.icq.com) Tel. DE: +49 177 9351947 ICQ#328449886 Tel. FR: +33 6 61925193 signature.pgp Description: Digital signature
Re: How to count new emails in mbox format mailbox?
On 25-12-2009, at 21h 12'52, Wu, Yue wrote about Re: How to count new emails in mbox format mailbox? Thanks, but that's the one part that I want to solve... I'm not familiar with sh script, the script I use for maildir is the follows: mailhier=~/.mutt/mails if [ $(find $mailhier -type f -print | wc -l) -ne 0 ]; then for d in $mailhier/* do if [ $(find $d -type f -print | wc -l) -eq 0 ]; then rm -r $d fi done fi I don't know how to do the same thing in sh script for mbox? Any one can figure me out of it? Your script does this: if [ number of regular files in $mailhier is not zero ] then for all folders in $mailhier/ do if [ number of regular files in $mailhier/folder is zero ] then delete folder fi done fi The thinking behind this for mbox format is different because you do not have so many files... A simply line will do: find $mailhier -empty -exec \rm -f {} \; or, if in a script, protect the sensitive characters (\, {, }, etc.): find $mailhier -empty -exec \\\rm -f \{\} \\\; Ionel
How to count new emails in mbox format mailbox?
Hi list: Now I've changed to mbox from maildir, when with maildir, I use a sh script to count the number of mails in directory new/ of each of my mails/ sub-directory, but now I don't know how to achieve it with mbox, any hint will be appreciated. -- Hi, Wu, Yue