Hi Franklin52,
I applied your given code, but it gave different output :
cat file1
ID, Name, Address, remark
001,AA,43,rrrr
002,FF,44,gg
cat file2
ID,marks,age
001,43,66
003,43,77
cat file3
ID, amount,balance
001,55,555
003,44,444
awk -F, '
> FILENAME=="file1"{a[$1]=$0}
> FILENAME=="file2" && a[$1] {for(i=2;i<=NF;i++){a[$1]=a[$1] FS $i};next}
> FILENAME=="file2" && !(a[$1]){a[$1]=$0}
> FILENAME=="file3" && a[$1] {for(i=2;i<=NF;i++){a[$1]=a[$1] FS $i};next}
> FILENAME=="file3" && !(a[$1]){a[$1]=$0}
> END{for(i in a)print a[i]}
> ' file1 file2 file3
OUTPUT is below:
002,FF,44,gg
003,43,77,44,444
ID, Name, Address, remark ,marks,age, amount,balance
001,AA,43,rrrr,43,66,55,555
Desired output should be like that:
ID, Name, Address, remark , marks, age, amount, balance
001, AA, 43, rrrr, 43, 66, 55, 555
002, FF, 44, gg
003, 43, 77, 44, 444