Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

extract data from a large file in Linux

Posted on 2014-07-24
4
Medium Priority
?
417 Views
Last Modified: 2014-07-24
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?

Regards,
Atorex
0
Comment
Question by:atorex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 40217421
grep -o -E "[^[:space:]]*@[^[:space:] ]*" inputfile | sort -u > outputfile

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

wmp
0
 

Author Comment

by:atorex
ID: 40217440
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
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40217469
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?
0
 

Author Comment

by:atorex
ID: 40217480
Sorry My bad, didn't see the updated command, and that works perfectly.

thanks for the help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question