awk -F "," '{ a=1
while ((getline p < ARGV[2]) > 0) {
props[a]=
a++
}
close(ARGV[2])
}
ARGIND > 1 { exit }
{ for (elem in props) {
if (length(props[elem]) = NF) {
split(props[elem],header,",")
for (item in header) {
data[header[item]+=$i ","
}
}
}
END {
for (elem in data) {
split(gensub(",$","","g",data[elem]),d,",")
print elem ":"
for ( e in d ) {
print d[e]
}
}
}' a.txt a.props.txt
This might work, but I did not tested it. And I would not recommend it with really large files as the scripts slurps them into memory. And what happens if a_props.txt contains two or more lines with the same field length e.g.:
name,age
name,email
This case is not handled in the above script! And the order of arguments to the script is important.