Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I am trying to find a linux command that will take the following text, and return just the email addresses that are immediately to the right of '<= '. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    16

    Returning the matched part of a search from each line


    Hi,
    I am trying to find a linux command that will take the following text, and return just the email addresses that are immediately to the right of '<= '.
    So it would return this:
    james@example.com
    fred@example.com
    mary@example.com
    max@example.com
    sam@example.com

    Many thanks for any help.

    2013-09-16 09:33:51 1VLVBm-0003JQ-Pz <= james@example.com id=00c101ceb2bf$b9ebd060$2dc37120$@example.com
    2013-09-16 09:35:18 1VLVDB-0003dp-Br <= fred@example.com id=5594BD88-15C6-4EF9-A63A-F8F9CC7E6770@example.com
    2013-09-16 09:35:41 1VLVDY-0003lv-SD <= mary@example.com id=026d01ceb2c0$1be5e800$53b1b800$@example.com
    2013-09-16 09:38:46 1VLVGY-0004LF-35 <= max@example.com id=CE5C9036.4C1FC%max@example.com
    2013-09-16 09:39:01 1VLVGm-0004OU-Ng <= sam@example.com id=CE5C9036.4C1FC%sam@example.com

  2. #2
    Just Joined!
    Join Date
    Oct 2012
    Posts
    13
    there may be more elegant way(s) to parse this, but as a quick and dirty solution the following will do the trick:

    Code:
    # cat /tmp/tmp.out
    2013-09-16 09:33:51 1VLVBm-0003JQ-Pz <= james@example.com id=00c101ceb2bf$b9ebd060$2dc37120$@example.com
    2013-09-16 09:35:18 1VLVDB-0003dp-Br <= fred@example.com id=5594BD88-15C6-4EF9-A63A-F8F9CC7E6770@example.com
    2013-09-16 09:35:41 1VLVDY-0003lv-SD <= mary@example.com id=026d01ceb2c0$1be5e800$53b1b800$@example.com
    2013-09-16 09:38:46 1VLVGY-0004LF-35 <= max@example.com id=CE5C9036.4C1FC%max@example.com
    2013-09-16 09:39:01 1VLVGm-0004OU-Ng <= sam@example.com id=CE5C9036.4C1FC%sam@example.com
    Code:
    # grep -Eo '<=[[:space:]].*@.*[[:space:]]' /tmp/tmp.out | cut -d ' ' -f2
    james@example.com
    fred@example.com
    mary@example.com
    max@example.com
    sam@example.com

  3. #3
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    224
    hi

    Code:
    sed -rn 's/.*<= ([^ ]*).*/\1/p' file

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •