Join 2 files

I have file1.txt

BGE179W1
BGE179W2
BGE179W3
BGE187W1
BGE187W2
BGE187W3
BGE194W1
BGE194W2
BGE194W3
BGE227W1
BGE227W2
BGE227W3
BGE288W1
BGE288W2
BGE288W3
BGE650W1

---------- Post updated at 12:41 AM ---------- Previous update was at 12:39 AM ----------

file 2 txt

BGE650W1,1,500,500,1
BGE227W3,1,500,500,0
BGE179W1,1,500,500,0
MDN987W2,1,500,500,1
MDN042W6,1,500,500,1
MDN161W6,1,500,500,0
MDN261W2,1,500,500,1
MDN250W3,1,500,500,1
LBP045W2,1,500,500,1
MDN146W3,1,500,500,1
MDN252W2,1,500,500,1
MDN223W5,1,500,500,0
MDN028W1,1,500,500,1
MDN267W2,1,500,500,1
MDN025W2,1,500,500,1
LBP122W1,1,500,500,1

---------- Post updated at 12:43 AM ---------- Previous update was at 12:41 AM ----------

expected result

BGE179W1,1,500,500,0
BGE179W2, , , , ,
BGE179W3, , , , ,
BGE187W1, , , , ,
BGE187W2, , , , ,
BGE187W3, , , , ,
BGE194W1, , , , ,
BGE194W2, , , , ,
BGE194W3, , , , ,
BGE227W1, , , , ,
BGE227W2, , , , ,
BGE227W3,1,500,500,0
BGE288W1, , , , ,
BGE288W2, , , , ,
BGE288W3, , , , ,
BGE650W1,1,500,500,1

---------- Post updated at 12:45 AM ---------- Previous update was at 12:43 AM ----------

i did this but still can't find desired result

awk -F, 'BEGIN{OFS=" "}FNR==NR{a[$1$2]=$3;next}($1$2 in a && $3=$3","a[$1$2])' file2.txt file1.txt > file3.txt

---------- Post updated at 12:47 AM ---------- Previous update was at 12:45 AM ----------

Try someting this:

awk 'NR==FNR{A[$1]=$0; n=NF; next} {if($1 in A) $0=A[$1]; else $n=$n }1' FS=, OFS=, file2 file1

it keep showing syntax error running the code mr scrutinizer...any suggestion?

What is the exact syntax error? If you are using Solaris try using /usr/xpg4/bin/awk instead of awk.

awk: syntax error near line 1
awk: illegal statement near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1

---------- Post updated at 01:30 AM ---------- Previous update was at 01:25 AM ----------

oh my gosh, so awesome..tks mr scrutz

---------- Post updated at 02:11 AM ---------- Previous update was at 01:30 AM ----------

how about this one

file1.txt

BGE179W1,1,500,500,1
BGE179W2,1,500,500,1
BGE179W3,1,500,500,1
BGE187W1,1,500,500,1
BGE187W2,1,500,500,1
BGE187W3,1,500,500,1
BGE194W1,1,500,500,1

---------- Post updated at 02:12 AM ---------- Previous update was at 02:11 AM ----------

file2.txt

BGE179W1,40,34,26,50
BGE179W2,35,46,65,78

---------- Post updated at 02:13 AM ---------- Previous update was at 02:12 AM ----------

i want the output like

BGE179W1,1,500,500,1,40,34,26,50
BGE179W2,1,500,500,1,35,46,65,78
BGE179W3,1,500,500,1, , , , ,
BGE187W1,1,500,500,1, , , , ,
BGE187W2,1,500,500,1, , , , ,
BGE187W3,1,500,500,1, , , , ,
BGE194W1,1,500,500,1, , , , ,

---------- Post updated at 02:32 AM ---------- Previous update was at 02:13 AM ----------

i use this

/usr/xpg4/bin/awk -F "," '{getline a < "file2.txt.dat"}NR==1{print a, $3, $4 "\n"}NR==3{print a, $3, $4}' OFS="," file1.txt

Try a small adaptation:

awk 'FNR==1{n+=NF} NR==FNR{i=$1; $1=x; A=$0; next} {if($1 in A) $0=$0 A[$1]; else $(n-1)=x }1' FS=, OFS=, file2 file1

--edit--
I removed one of the empty fields in the output, because I figured there might be one too many in your sample..