I'm trying to figure out how to do this sequence in this bash script. The problem I'm having is how to make $i to change according to the changes in $x
My current solution is a bit of a hack and stupid. One more thing, my current solution will parse the file _each_ time for _each_value/head which essentially means it reads the file multiple times. Is there a better way so to reduce the # of reads/parses? (Does awk parse the file once or multiple times, that is if I were to rewrite the below entirely in awk language) Thanks #!/bin/bash filename=$1 heads=6 tpi=7 x=0 y=1 z=1 clear while (( $x < $heads )) do finaltpi=`cat $1 | awk "/TPI chosen/" | awk -v pat="$x" '{if (NR==pat+1) print $5}'` while (( $y <= $tpi )) do if [ "$x" -eq 0 ] then for i in `seq 1 7` <----- do tpiert=`egrep -i "(average)" $1 | awk -v pat="$i" '{ if(NR==pat) print $5","$10}'` echo $filename,$x,$y,$finaltpi,$tpiert ((y++)) done elif [ "$x" -eq 1 ] then for i in `seq 8 14` <----- do tpiert=`egrep -i "(average)" $1| awk -v pat="$i" '{ if(NR==pat) print $5","$10}'` echo $filename,$x,$y,$finaltpi,$tpiert ((y++)) done elif [ "$x" -eq 2 ] then for i in `seq 15 21` <----- do tpiert=`egrep -i "(average)" $1 | awk -v pat="$i" '{ if(NR==pat) print $5","$10}'` echo $filename,$x,$y,$finaltpi,$tpiert ((y++)) done elif [ "$x" -eq 3 ] then for i in `seq 22 28` <----- do tpiert=`egrep -i "(average)" $1 | awk -v pat="$i" '{ if(NR==pat) print $5","$10}'` echo $filename,$x,$y,$finaltpi,$tpiert ((y++)) done elif [ "$x" -eq 4 ] then for i in `seq 29 35` <----- do tpiert=`egrep -i "(average)" $1 | awk -v pat="$i" '{ if(NR==pat) print $5","$10}'` echo $filename,$x,$y,$finaltpi,$tpiert ((y++)) done elif [ "$x" -eq 5 ] then for i in `seq 36 42` <----- do tpiert=`egrep -i "(average)" $1 | awk -v pat="$i" '{ if(NR==pat) print $5","$10}'` echo $filename,$x,$y,$finaltpi,$tpiert ((y++)) done fi done let "y=1" ((x++)) done -- gentoo-user@gentoo.org mailing list