1843977 Members
1574 Online
110226 Solutions
New Discussion

help shell script

 
SOLVED
Go to solution
Jairo Campana
Trusted Contributor

help shell script

hello i have a problem
in fileA I need to exclude domains from email that belong to another file
example fileA
cat fileA
yahoo.com
hotmail.com
hp.com
********************************
cat fileB
jhon@yahoo.com
postmaster@hotmail.com
**********************************
grep -v hotmail.com fileB --->this works

in script:
cat fileA|while read domain; do grep -v $domain fileB ; done

this not works

for i in `cat fileA`
do
grep -v $i fileB
done

this not works

the problem is the name@domain grep -v domain


legionx
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: help shell script

Hi Jairo:

# cat fileA
yahoo.com
hotmail.com
hp.com

# cat fileB
jhon@yahoo.com
postmaster@hotmail.com
somebody@xyz.com
anotherbody@bigdot.com

# grep -F -v -f fileA fileB
somebody@xyz.com
anotherbody@bigdot.com

Regards!

...JRF...
Arturo Galbiati
Esteemed Contributor

Re: help shell script

Hi Jairo,
this should work:
grep -vf fileA fileB

HTH,
Art