Quoth vinurs on Thursday, 12 April 2012:
> Hi,all
>        I am a newcomer to mutt, Is there any method to show that how
> many new mails and how many mails in all in my mailboxs
>        i read the mutt manual ,but i can not find a command to get the result!
>        for example, i have a inbox call gmail, in it, there has 15 new
> mails and 30 mails in all, then i want a mutt command to return the
> numbers and let other shell command use it!

If you're using mbox format, then this ruby script will output the number
of new messages in an mbox passed as an argument or piped to its stdin:

#!/usr/bin/env ruby
UNIX_FROM = /^From \S+ ([A-Z][a-z]{2} ){2}[\s\d]\d \d{2}:\d{2}:\d{2} \d{4}$/
newmail=0
in_hdr=false
$<.each do |line|
  case line
    when UNIX_FROM
      newmail += 1
      in_hdr = true
    when /^Status: RO/
      newmail -= 1 if in_hdr
    when /^\s*$/
      in_hdr = false
  end
end
puts newmail

-- 
.O. | Sterling (Chip) Camden      | http://camdensoftware.com
..O | [email protected] | http://chipsquips.com
OOO | 2048R/D6DBAF91              | http://chipstips.com

Attachment: pgphiT68bnRUJ.pgp
Description: PGP signature

Reply via email to