n="1 2 3 4 5 6 7 8 9 10" noFirstLine() { cat - | gawk 'NR==1 {next} {print}' ; } tac() { gawk 'BEGIN { N=1 } { L[N++]=$0 } END { while(N--) print L[N]} ' } for i in $n; do cat /Users/timm/Downloads/2009MarDataA/DATA-${i}Genes-RankByAvgMerit/BestAvaj.txt | noFirstLine | tac | gawk ' #{ OFS=","; print ">> " $0 , NF} $2 != Study {Study=$2; Max=$8; Out="/tmp/report_" Study "_" I ; printf ""> Out } NF >= 8 { print $6 , $8 > Out } ' I=$i done Classes=`ls /tmp/report* | sed 's/.tmp.report_//' | sed 's/_.*//' | sort | uniq` for K in $Classes; do paste /tmp/report_${K}_1 /tmp/report_${K}_2 /tmp/report_${K}_3 /tmp/report_${K}_4 /tmp/report_${K}_5 \ /tmp/report_${K}_6 /tmp/report_${K}_7 /tmp/report_${K}_8 /tmp/report_${K}_9 /tmp/report_${K}_10 \ | gawk ' NR==1 {Max=$NF} { $2 /= Max $4 /= Max $6 /= Max $8 /= Max $10 /= Max $12 /= Max $14 /= Max $16 /= Max $18 /= Max $20 /= Max OFS="\t" print $0 }' > /tmp/summary_$K gnuplot<