All pastes #956545 Raw Edit

Someone

public text v1 · immutable
#956545 ·published 2008-03-25 11:56 UTC
rendered paste body
#!/bin/bash


myFileHodn="hodnoceni.txt"
myFileStud="students.txt"


for (( i=1 ; i <= $# ; i++ )) ;do
     eval arg='$'$i
     if ["$arg" = "-h"] ;then i=`expr $i + 1`; eval arg='$'$i ; myFileHodn=$arg
     elif ["$arg" = "-s"] ;then i=`expr $i + 1`; eval arg='$'$i ; myFileStud=$arg
     elif ["$arg" = "-v"] ;then i=`expr $i + 1`; eval arg='$'$i ; omezeni=$arg
     else echo "$arg je neznamy argument." ; exit
     fi
     done

a='RETAZEC_KTORY_NIKTO_NIKDY_NEPOUZIJE'

  echo '' > xxxtemp.txt
  cat $myFileHodn | while myLineHodn=`line`
  do


     temphodn="$allFile"
     allFile="$temphodn $myLineHodn" 

     output=`echo $myLineHodn | sed -e "s/ /$a/mg"`
     output=`echo $output | sed -e 's/;/ /mg'`

     counter=0
     for word in $output ; do
	eval xhodn_$counter='`echo $word | sed -e "s/$a/ /mg"`'
	let counter++  # increasing counter
     done

       cat $myFileStud | while myLineStud=`line`
       do

         tempstud="$allFile"
         allFile="$tempstud $myLineStud"

         output=`echo $myLineStud | sed -e "s/ /$a/mg"`
         output=`echo $output | sed -e 's/;/ /mg'`

         counter=0
         for word in $output ; do
	    eval xstud_$counter='`echo $word | sed -e "s/$a/ /mg"`'
	    let counter++  # increasing counter
         done



if [ "$xstud_1" = "" ] ; then continue ; fi ;

if [ "$xhodn_0" = "$xstud_1" ] ;then if [ "$xhodn_1" = "A" ] ;then xstud_2=$xhodn_2
                                   elif [ "$xhodn_1" = "a" ] ;then xstud_2=$xhodn_2
                                   elif [ "$xhodn_1" = "B" ] ;then xstud_3=$xhodn_2
                                   elif [ "$xhodn_1" = "b" ] ;then xstud_3=$xhodn_2
                                   elif [ "$xhodn_1" = "C" ] ;then xstud_4=$xhodn_2
                                   elif [ "$xhodn_1" = "c" ] ;then xstud_4=$xhodn_2
                                   elif [ "$xhodn_1" = "E" ] ;then xstud_5=$xhodn_2
                                   elif [ "$xhodn_1" = "e" ] ;then xstud_5=$xhodn_2
fi
fi

xstud_6=`expr $xstud_2 + $xstud_3`
xstud_6=`expr $xstud_6 + $xstud_4`
xstud_6=`expr $xstud_6 + $xstud_5`

echo "$xstud_0;$xstud_1;$xstud_2;$xstud_3;$xstud_4;$xstud_5;$xstud_6" >> xxxtemp.txt

done
mv xxxtemp.txt "$myFileStud"

done