Check your unread GMail e-mails using the Linux command line

By | January 21, 2011

All you need to display your latest GMail messages in the command line is this one-liner:

curl -u username: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”

Substitute username:password with your GMail username and password.

6 thoughts on “Check your unread GMail e-mails using the Linux command line

  1. erickjohncuevas

    bash: syntax error near unexpected token `(‘

    that was the error.

    Reply
  2. T4L Post author

    Replace the “” and ‘ characters because WordPress changes them

    Reply
  3. John

    Is there a command that can be added so that if it comes back saying new emails 1 or more then it’ll open gmail.com through say firefox?

    Reply
  4. drsn

    any one now how to convert html file to text file using html2text using direct url link

    Reply
  5. Jonathan

    It gives me this reponse to cURL:

    Unauthorized

    Unauthorized
    Error 401

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *