transpose() { cat - | gawk -F, 'BEGIN{OFS=","} NR == 1 { n = NF for (i = 1; i <= NF; i++) row[i] = $i next } { if (NF > n) n = NF for (i = 1; i <= NF; i++) row[i] = row[i] "," $i } END { for (i = 1; i <= n; i++) print row[i] }' } sortCols() { cat - | gawk -F, 'BEGIN{FS=","; OFS=","}{for(i=1;i<=NF;i++) $i=$i; print $103,$95,$99,$92,$93,$96,$97,$98,$100,$101,$58,$59,$4,$5,$102,$13,$14,$94,$67,$68,$71,$85,$86,$17,$72,$78,$6,$70,$79,$7,$89,$76,$77,$90,$62,$8,$31,$32,$36,$84,$49,$50,$69,$87,$88,$63,$74,$9,$65,$18,$83,$56,$2,$27,$40,$41,$81,$82,$10,$47,$45,$73,$91,$53,$66,$3,$60,$54,$57,$35,$22,$23,$80,$26,$38,$11,$51,$16,$15,$44,$42,$52,$61,$39,$43,$34,$29,$48,$25,$24,$33,$12,$20,$30,$55,$64,$46,$19,$28,$37,$21,$75 }' } for i in *mreValuesToWrite.txt;do rm transposed.dat rm sorted.dat echo "${i%mreValuesToWrite.txt}" cat $i | transpose > transposed.dat cat transposed.dat | sortCols > sorted.dat cat sorted.dat |awk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1 && $i 2d0.dat cat sorted.dat |awk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1 && $i 2d25.dat cat sorted.dat |awk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1 && $i 2d50.dat cat sorted.dat |awk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1) print NR,i}' T1=1.5 > 2d75.dat gnuplot < & >=0" with points 6 5,\ "2d25.dat" title "1.0> & >=0.5" with points 5 5,\ "2d50.dat" title "1.5> & >=1" with points 8 5,\ "2d75.dat" title ">=1.5" with points 7 5 EOF epstopdf "${i%mreValuesToWrite.txt}MREValues.eps" done