I have several txt files and would like to extract email from that file if file contains text "Provider" inside. Text files are not equally formatted. "provider" could be anywhere in text.
Here is some short sample :
file 1.txt
Name: Joe1
Provider
...
Email [email protected]
file 2.txt
Name: Joe2
...
Client
...
Email [email protected]
file 3.txt
Name: Joe3
...
Provider
Email [email protected]
I am using this short code but it returns all emails
$ awk -F, '{
for (i=1; i<=NF; i++)
if ($i ~ /@/)
print $i
}' *
Can you help me out?
Thanks