Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a log file which contains a lot of text as shown below. Would like to extract the email address which falls between emailAddress and status strings. I am open to any option which runs on Ubuntu, but would like to automate it.


share|improve this question
up vote 1 down vote accepted

Here you go:

perl -ne 'if(/emailAddress..:..(.+?)\\\"/){print "$1\n"}' logfile.txt

This Perl snippet will go through the file line by line and look for the string "emailAddress" followed by:

  • any two characters (..), this will match \",
  • :,
  • any two characters (..), this will match \".

It then saves the following characters (until the next ") into $1. Finally, it prints $1.

NOTE: This assumes that every email address in your logfile has the same format as what you have given in your question.

share|improve this answer
Thanks @terdon - worked like a charm – Praveen Sripati Nov 30 '12 at 13:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.