Skip to content

Instantly share code, notes, and snippets.

@limed
Last active December 23, 2015 02:39
Show Gist options
  • Select an option

  • Save limed/b0b1e96bee3fe0b95915 to your computer and use it in GitHub Desktop.

Select an option

Save limed/b0b1e96bee3fe0b95915 to your computer and use it in GitHub Desktop.
This basically iterates through all the mailbox folders and counts the number of mail a particular mailbox has
#!/bin/bash
for i in `zmprov -l gas | grep 'mbox'`; do
for j in $( zmprov -l gaa -s ${i} | egrep -v "^(spam|ham)" ); do
total=0
echo -n "Total emails for $j = "
for k in $( zmmailbox -z -m "$j" gaf | awk '{print $4}' | egrep -o "[0-9]+" ); do
total=$(( total + k ))
done
echo $total
done > /tmp/megacounteroutfile/${i}.outfile;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment