I would not recommend this because this solution :
do a useless use of cat (UUOC)
and may lead to duplicate entries since it loops many times on file2.
You have to consider whether it can happen in fil1 that some entries are substring of other entries and may potentially match line that are in file2 but that we don't want to filter out.
Consider for example :
file1 :
US
AUS
file2 :
AUS,123
NZ,11
US,13
USA,12
then something like this may works:
$ sed 's/.*/^&,/' f1 >f1.tmp ; grep -vEf f1.tmp f2 ; rm -f f1.tmp
NZ,11
USA,12
of course it's just an example. It depends on what you may have as input and what you want as output.
But can it happend that the pattern appear somewhere else than at the beginning of the line ?
yes the patten may appear at any of the file but i need to check the first string to be checked only and extact string from file1 needs to be matched
what i actually needed is