Tag Archives: Command Line Tricks

How To Check Unread Gmails From Linux Command Line Without Opening Any Browser ?

Here’s a command, if you use Gmail and like to check for unread email without having to opening up a browser. This command makes use of: curl, tr, awk, andsed and looks like:

curl -u GMAIL_ADDRESS:GMAIL_PASSWORD –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”

Where GMAIL_ADDRESS is your actual gmail address and GMAIL_PASSWORD is your gmail password. After successful authentication the sender and subject of your unread Gmail will be printed out.