Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example:
I have files in below format
file 1:

zxc,133,joe@example.com
cst,222,xyz@example1.com

File 2 Contains:

hxd
hcd
jws
zxc
cst

File 1 has 50000 lines and file 2 has around 30000 lines :

Expected Output has to be :

hxd
hcd
jws

Tried the below Code.Doesnt work

awk 'BEGIN {
 IGNORECASE = 1;
 FS =OFS = ","
  }
  NR == FNR {
  f[$1] ! = $0
  next
  }
$1 in f {
  print $1 > "finaloutput.csv";
  }' file1.csv  file2.csv
awk 'BEGIN {
 IGNORECASE = 1;
 FS="."
  }
  NR == FNR {
  f[$1]
  next
  }
$1 in f {
  print $1, $0
  }' file2.csv  file1.csv
1 Like

With the renewed content of post #1 (please in future create a new post instead) try:

awk 'NR==FNR{A[$1]; next} !($1 in A)' IGNORECASE=1 FS=, file1 FS=" " file2

If you don't insist on awk , try

$ sort -t, file[12] | uniq -uw3
hcd
hxd
jws

Using bash and GNU grep.

grep -v -Ff <(cut -d',' -f 1 testfile1.csv) testfile2.csv > resultfile.csv

Hello TestPractice,

You have NOT haven't phrased your problems clearly in your post, based on your output shown I come up with this.
As per your shown samples I have not used ignorecase here.

awk 'FNR==NR{a[$1];next} !($0 in a)' FS="," Input_file1 FS=" " Input_file2

Thanks,
R. Singh