Skip to content

Instantly share code, notes, and snippets.

@jfcarr
Created July 4, 2017 14:17
Show Gist options
  • Save jfcarr/c68e3b2677cdcd74b484f2524f7a3bdb to your computer and use it in GitHub Desktop.
Save jfcarr/c68e3b2677cdcd74b484f2524f7a3bdb to your computer and use it in GitHub Desktop.
Show unread Gmail message count.
#!/bin/bash
LASTGMAIL="$(curl -u johndoe:mypassword --silent 'https://mail.google.com/mail/feed/atom' | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n 's/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p' | wc -l)"
if [ $LASTGMAIL -ne 0 ]
then
echo "$LASTGMAIL : [email protected]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment