Multiple file lookup using awk

I want to lookup filea with fileb,filec and filed.
If entry in filea exist in fileb and filec mark Y and then if entry in filea exist in filed mark as Y.
Final output should have all the entries from filea.

This prints only matching entries from file a in fileb i want all entries from filea if it exists or not in fileb

nawk -F"|" 'NR==FNR{a[$1];next} $1 in a{print $1} filea fileb

you can use while loops inside awk to get your file items into arrays.

Can you help me write the code

no. i will not because you are not putting in effort. always look up the manual or google if you don't know anything. this page. there is example of using while loop.

instead of while/getline combo for reading the files, you could could use a separate combos of FILENAME/ARGV and read the files into arrays. Checking the content of 'filea' in multiple read-in arrays should be straight-forward.
Search the forums for the terms mentioned above and it should give you enough as a starting hint.
Good luck.

All,

Here is my effort:

BEGIN {FS=","}
for (i=0;i< ARGC;i++)
{ARGV=="fileb"{b[$1]++}
ARGV=="filec"{c[$1]++}
ARGV=="filed"{d[$1]++}
ARGV=="filea"{if (($1 in b ) && ( $1 in c) && ($1 in d)) print $1,"Y" OFS
else
if (($1 in d) && !($1 in c) && !($1 in b)) print $1 OFS,"Y"
else
if (($1 in b) && ($1 in c) && !($1 in d)) print $1,"Y"OFS
else print $1 OFS OFS
}} OFS=","

command used : nawk -f awkfiles.awk fileb filec filed filea
Here is the error:

Requirement:
Field 1 Filed2 Field 3
$1 of filea|"Y" if $1 of filea exist in fileb and filec| "Y" if $1 of filea exist in filed

Output needed:
abc,Y,
def,,
ghi,,Y
jkl,,Y

Your help is appreciate in fixing this.

This so called 'effort' looks suspiciously similar to a previously posted and deleted suggestion with some minor cosmetic changes.

This is hard effort of person who is familar with 2 files lookup and not with multiple files and with argv

Appreciate help

Given the 'Search' capability of the forums and 'hints' given in the previous posts.......

nawk -f 3fileLookup.awk fileb filec filed filea

3fileLookup.awk:

BEGIN {
  FS=OFS=","
}
FILENAME == ARGV[1] {
   b[$1]++
   next
}
FILENAME == ARGV[2] {
   c[$1]++
   next
}
FILENAME == ARGV[3] {
   d[$1]++
   next
}
{
  print $1, ($1 in b && $1 in c)?"Y":"", ($1 in d)?"Y":""
}

Here is what i coded with 2 file lookup at a time, this works but creates unneccessary intermediate files

nawk -F"|" 'NR==FNR{a[$1];next} {if($1 in a) print $1,"Y"; else print $1 OFS}'  OFS="|"  fileb filea > out 
nawk -F"|" 'NR==FNR{a[$1];next} {if($1 in a) print $0,"Y"; else print $0 OFS}'  OFS="|"   filec out > out1

nawk -F"|" 'NR==FNR{a[$1];next} {if($1 in a) print $0,"Y"; else print $0 OFS}'  OFS="|"  filed out1 > out2

nawk -F"|" '{if ($2 =="Y" && $3 == "Y") print $1,"Y",$4 ;else print $1 OFS OFS $4}' OFS="|"  outing2

Thanks Vrgesh99