about summary refs log blame commit diff stats
path: root/bin/newmail.sh
blob: a9da32bd41f89011f3fca60b583bc3ab4ca61317 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14

                     

                                       









                                                                    
#!/usr/local/bin/bash

# Notifies users of newly received mail

NewMail(){
    NEWMAIL=$(mailx &)
    UNREAD=$(echo $NEWMAIL |grep -o 'messages.*new' | cut -f2 -d" ")
}
NewMail # call NewMail function
UNREAD=${UNREAD/>/}

if [ -n "$UNREAD" ]; then
    echo "`whoami` you have $UNREAD new mail(s) "
fi