• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 431
  • Last Modified:

extract data from a large file in Linux

I have a file with thousands of email, names and addresses and so on I need to extract just the email address and pipe that to a new file.
What would be the easiest grep command to do so?

  • 2
  • 2
1 Solution
grep -o -E "[^[:space:]]*@[^[:space:] ]*" inputfile | sort -u > outputfile

"sort -u" above is meant to remove duplicates.

atorexAuthor Commented:
the below is what I get, its not getting just email addresses.

Brodner      0.0875      +37.76907      122.444      1      1      1      haight@gin.com      STORE      CALI      San
Byun      0.0925      +41.81192      87.6873      1      1      1      wickerpark@gin.com      STORE      CENTRAL      Chicago      en_US      USD            
Cruz      0.095      +47.43225      121.803      1      1      1      pikeplace@gin.com      STORE      NOWEST      Seattle      en_US      USD            
Cutler      0      +40.68494      73.9806      1      1      1      parkslope@gin.com      STORE      EAST      New
Dworkin      0.09      +33.78659      118.299      1      1      1      larchmont@gin.com      STORE      CALI      Los

Sample input file,

UPDATE      RETAIL_LOCATION      1031      1031      West Pearl      BLD-PERL      943 Pearl St                  Boulder      CO      80302      US                                          0.0836      40.017415      105.283      1      1      1      westpearl@gin.com      STORE      NOWEST      Boulder      en_US      USD
It works perfectly for me using your data.

What is your OS, what do you get with "grep --version"?

Did you exactly use my code, including the "[:space:]" stuff I added later?
atorexAuthor Commented:
Sorry My bad, didn't see the updated command, and that works perfectly.

thanks for the help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now