rendered paste body#!/bin/bash
myFileHodn="hodnoceni.txt"
myFileStud="students.txt"
omezeni="A-Z"
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 read myLineHodn
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 read myLineStud
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 if [[ "A" =~ "[$omezeni]" ]] ;then xstud_2=$xhodn_2
elif [ "$xhodn_1" = "a" ] ;then if [[ "a" =~ "[$omezeni]" ]] ;then xstud_2=$xhodn_2
elif [ "$xhodn_1" = "B" ] ;then if [[ "B" =~ "[$omezeni]" ]] ;then xstud_3=$xhodn_2
elif [ "$xhodn_1" = "b" ] ;then if [[ "b" =~ "[$omezeni]" ]] ;then xstud_3=$xhodn_2
elif [ "$xhodn_1" = "c" ] ;then if [[ "c" =~ "[$omezeni]" ]] ;then xstud_4=$xhodn_2
elif [ "$xhodn_1" = "C" ] ;then if [[ "c" =~ "[$omezeni]" ]] ;then xstud_4=$xhodn_2
elif [ "$xhodn_1" = "D" ] ;then if [[ "D" =~ "[$omezeni]" ]] ;then xstud_5=$xhodn_2
elif [ "$xhodn_1" = "d" ] ;then if [[ "d" =~ "[$omezeni]" ]] ;then xstud_5=$xhodn_2
elif [ "$xhodn_1" = "e" ] ;then if [[ "E" =~ "[$omezeni]" ]] ;then xstud_6=$xhodn_2
elif [ "$xhodn_1" = "E" ] ;then if [[ "e" =~ "[$omezeni]" ]] ;then xstud_6=$xhodn_2
fi
fi
fi
xstud_7=`expr $xstud_2 + $xstud_3`
xstud_7=`expr $xstud_7 + $xstud_4`
xstud_7=`expr $xstud_7 + $xstud_5`
xstud_7=`expr $xstud_7 + $xstud_6`
echo "$xstud_0;$xstud_1;$xstud_2;$xstud_3;$xstud_4;$xstud_5;$xstud_6;$xstud_7" >> xxxtemp.txt
done
mv xxxtemp.txt "$myFileStud"
touch xxxtemp.txt
done
rm xxxtemp.txt