How can I grep out only the email address using a regex from a file with multiple lines similar to this. (a sql dump to be precise)
Unfortunately I cannot just go b
You can solve it using python with the help of the built-in csv module and the external validators module, like this:
import validators
import csv
import sys
with open(sys.argv[1], newline='') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
for field in row:
if validators.email(field):
print(field)
Run it like:
python3 script.py infile
That yields:
cgreen@blah.com