Problem writing a search script

I trying to write a script in bash that take a list of users in �fileA� and searches another list user in �fileB� if the user does not exist in �file B� write the user to another file �file C�.

Please note �fileA� and �fileB� contains over 1000 users

Basically

�fileA�          �fileB�

Abc                 Tom
Def                 John
Tom                 Jonathan
Paul                 Paul
Wood              Graham

Result in FileC

Abc
Def
Wood

Here my attempt

for i in `cat fileA`; do grep �w $i fileB; test [$? �ne 0] && echo $i >fileC  fi; done

Can you help please my attempt is not working?
Thanks

nawk 'FNR==NR{fB[$0];next} !($0 in fB)' fileB fileA > fileC 

Hassan,

Your code looks fine except for below error:

 
for i in `cat fileA`; do grep -w $i fileB; test [$? -ne 0] && echo $i >>fileC  fi; done

You need ">>" before fileC so that the users are appended. Else only the last user in file1 that is not present in file2 would be present in file3.

Thanks,
Vijay V Menon