Solução awk complexa para qualquer número de campos:
awk 'function pr(a, len){ # print an integral(joined) line
for (i=1; i<=len; i++) printf "%s%s",a[i],(i==len? ORS : ",")
}
NR<3;{ f=($0~/^[0-9]+,/? 1:0) } # 'f' flag, points to a 'basic' line(starting with digit)
NR>2{
if (f && a[1]){ pr(a, len) }
len=(f? split($0,a,",") : split($0,b,",")); # split into different arrays
if (!f) { # encountering subsequent line
for(i=2; i<=len; i++)
if(b[i]!="") a[i]=a[i]"#"b[i] # append subsequent values to 'basic' line
}
}END{ pr(a, len) }' file
A saída:
col1,col2,col3,col4,col5
1,val1#val2#val3#val4#val5,57,val1#val2#val3#val4#val5,TRUE
2,val1#val2#val3#val4#val5,878,val1#val2#val3#val4#val5,FALSE