Please correct my Script

I am new to awk, can somone please correct the following script

awk -F "," 'BEGIN {
foreach ((getline < "file1.csv") > 0)
{i++
a[i]=1 --> assuming the first column in the row will be stored in a[]
foreach (a [i]in f1) {
if (a [i]== $5) continue
print a[i];
}
}
} file2.csv'

Here is what I want to do

File 1
laeg.com,2/2/23,a,b,ga
aeg.com,2/2/23,a,b,ga
xyz.com,2/2/12,a,b,c
eg.com,2/2/23,a,b,ga

File 2
1,2,ua,xyz.com
1,2,ua,abc.com
1,2,ua,eg.com
1,2,ua,easg.com
1,2,ua,zth.com

File 3
laeg.com,2/2/23,a,b,ga
aeg.com,2/2/23,a,b,ga

while reading in file1 it should compare in each row on file2 if found any where in the file2 it should be ignored while writing into output file.

try this

awk -F"," 'FILENAME=="file2"{A[$4]=$4}
FILENAME=="file1"{if(!A[$1]){print}}' file2 file1>file3

Vidhyadhar,

Can you please explain this command.
I tried but invain

which part you didn't understood??

Sorry vidhyadhar,

Its not working. The result should be

laeg.com,2/2/23,a,b,ga
aeg.com,2/2/23,a,b,ga

Where as its listing entire file1 contents

Thanks

This works

nawk -F"," 'FILENAME="file1"  {array[$1]=$1} FILENAME="file2" { if (array[$4]) {print $0}}' file1 file2

Sorry siquadri,

prints nothing.

Did you change your input file names to file1 and file2

Here is what i did

-bash-2.05b$ cat file1.txt
laeg.com,2/2/23,a,b,ga
aeg.com,2/2/23,a,b,ga
xyz.com,2/2/12,a,b,c
eg.com,2/2/23,a,b,ga
-bash-2.05b$ cat file2.txt
1,2,ua,xyz.com
1,2,ua,abc.com
1,2,ua,eg.com
1,2,ua,easg.com
1,2,ua,zth.com
-bash-2.05b$

-bash-2.05b$ awk -F"," 'FILENAME="file1.txt" {array[$1]=$1} FILENAME="file2.txt" { if (array[$4]) {print $0}}' file1.txt file2.txt
-bash-2.05b$ awk -F"," 'FILENAME="file1.txt" {array[$1]=$1} FILENAME="file2.txt" { if (array[$4]) {print $0}}' file1.txt file2.txt > file3.txt
-bash-2.05b$ cat file3.txt
-bash-2.05b$

This is what i am getting

$ awk -F"," 'FILENAME="file1.txt" {array[$1]=$1} FILENAME="file2.txt" { if (array[$4]) {print $0}}' file1.txt file2.txt
1,2,ua,xyz.com
1,2,ua,eg.com
$

What could have gone wrong ? this is strange

I use

Linux 2.6.9-22.ELsmp #1 SMP Sat Oct 8 19:11:43 CDT 2005 i686 i686 i386 GNU/Linux

Siquadri, any idea why it could have failed at my end ?