Попробуйте paste
объединить четыре строки в одну, read
объединить их в четыре переменные, добавив каждую к выходным строкам:
paste -s -d" \n" file |
{ while read A B C D
do L1="$L1$DL$A"
L2="$L2$DL$B"
L3="$L3$DL$C"
L4="$L4$DL$D"
DL=,
done
printf "%s\n" "$L1" "$L2" "$L3" "$L4"
}
col1,col2,col3,col1,col2,col3,
1,disease1,high,2,disease1,low,
1,disease2,low,2,disease2,low,
1,disease3,high,2,disease3,high,
РЕДАКТИРОВАТЬ:или, немного проще, paste
не нужно:
while read A && read B && read C && read D
do L1="$L1$DL$A"
L2="$L2$DL$B"
L3="$L3$DL$C"
L4="$L4$DL$D"
DL=,
done < file
printf "%s\n" "$L1" "$L2" "$L3" "$L4"