This commit is contained in:
Arkadiusz Hypki 2023-05-22 13:35:25 +02:00
commit d18ee6abe3

View File

@ -4,14 +4,15 @@
#numOfPeople=`cat $1 | grep $2 | wc -l`
#echo "Num. of people from $2 is $numOfPeople"
echo "Podaj nazwę pliku z bazą danych"
read inPlikWej
echo "Podaj minimalny wiek"
echo "Podaj plik z danymi"
read inPlik
echo "Podaj wiek"
read inWiek
echo "Podaj kraj"
read inKraj
w=0
declare -A kraje
ile=0
wszyscy=0
# iterating line-by-line
while read line
@ -24,16 +25,17 @@ country=`echo $line | cut -d " " -f 3`
if [ $name != "#" ]
then
w=$((w + 1))
wszyscy=$((wszyscy+1))
if [ $age -ge $inWiek ]
if [ $country = "$inKraj" -a $age -ge $inWiek ]
then
kraje["$country"]=$((kraje["$country"] + 1))
ile=$((ile+1))
echo "Person $name (from $country) is $age years old"
fi
fi
done < $inPlikWej
done < $inPlik
for key in ${!kraje[@]}; do echo "From $key there is ${kraje["$key"]} persons"; done
#echo "There is $ile people from $inKraj (from all $wszyscy people)"
echo "There is `echo "scale=2; $ile/$wszyscy*100.0" | bc -l`% people from $inKraj"