Computing statistics with percent how many people comes from a given country

This commit is contained in:
Arkadiusz Hypki 2023-05-15 18:05:39 +02:00
parent c7b1fb7e0f
commit d7c3c77ef7

View File

@ -11,6 +11,8 @@ read inWiek
echo "Podaj kraj"
read inKraj
ile=0
wszyscy=0
# iterating line-by-line
while read line
@ -23,11 +25,17 @@ country=`echo $line | cut -d " " -f 3`
if [ $name != "#" ]
then
wszyscy=$((wszyscy+1))
if [ $country = "$inKraj" -a $age -ge $inWiek ]
then
ile=$((ile+1))
echo "Person $name (from $country) is $age years old"
fi
fi
done < $inPlik
#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"