Linux grep/egrep command problem So I have a very big database, the question is
ID: 3887625 • Letter: L
Question
Linux grep/egrep command problem
So I have a very big database, the question is to find out the incorrect format e-mail address. Please help me, thank you!
1:How many records have incorrect email addresses (lines with an @ in it but formatted incorrectly)? An email address has a user-id and domain names can consist of letters, numbers, periods, and dashes. An email address should have a top-level-domain (something.top-leveldomain). Top-level-domains are of the form: com, org, edu etc.,
I know how to find the email address: grep -E "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}" HW1_Data.txt;
But if I use grep -E -v "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}" HW1_Data.txt, I will ust got everything but email..so I just don't know how to do
Explanation / Answer
Answer is as follows:
After examining I will found that using grep - E -v " ....................................." command is used only the part grep -E is usefull only for one line.
To overcome this problem use the "egrep" instead of grep with E switch command because in grep statement the symbols like %, + etc are treated as pattern. if they does not presdent in the format then they revoke the command.So we use egrep command instead of grep because egrep treated the symbols as meta characters
The command with egrep is as follows:
egrep -v "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,6}" HW1_Data.txt
if there is any query please ask in comments........
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.