#!/bin/bash MAILDIR=~/Mail MAILBOXES=$(ls -1 $MAILDIR/) TOTAL=0 for MBOX in $MAILBOXES do MAILCOUNT=$(ls -1 "$MAILDIR/$MBOX/new" 2>/dev/null | wc -l) if [ $MAILCOUNT -ne 0 ] then RESULT="${RESULT}\n${MAILCOUNT}\t${MBOX##*/} " TOTAL=$(($TOTAL+$MAILCOUNT)) fi done RESULT="${RESULT}\nTotal:\t$TOTAL\n" if [ "$1" = '-c' ] then clear fi echo -e "$RESULT" exit 0