ex1.sh changed to make a statistics for all countries at once - it prints everything at the end
This commit is contained in:
parent
de44f3ece7
commit
2129be264a
@ -6,13 +6,12 @@
|
||||
|
||||
echo "Podaj nazwę pliku z bazą danych"
|
||||
read inPlikWej
|
||||
echo "Podaj kraj, który wyszukać"
|
||||
read inKraj
|
||||
echo "Podaj minimalny wiek"
|
||||
read inWiek
|
||||
|
||||
w=0
|
||||
sz=0
|
||||
|
||||
declare -A kraje
|
||||
|
||||
# iterating line-by-line
|
||||
while read line
|
||||
@ -27,9 +26,9 @@ then
|
||||
|
||||
w=$((w + 1))
|
||||
|
||||
if [ $country = "$inKraj" -a $age -ge $inWiek ]
|
||||
if [ $age -ge $inWiek ]
|
||||
then
|
||||
sz=$((sz + 1))
|
||||
kraje["$country"]=$((kraje["$country"] + 1))
|
||||
echo "Person $name (from $country) is $age years old"
|
||||
fi
|
||||
|
||||
@ -37,4 +36,4 @@ fi
|
||||
|
||||
done < $inPlikWej
|
||||
|
||||
echo "There is statistically `echo "scale=2; $sz/$w*100.0" | bc -l` % of such persons"
|
||||
for key in ${!kraje[@]}; do echo "From $key there is ${kraje["$key"]} persons"; done
|
||||
|
Loading…
Reference in New Issue
Block a user