Computing statistics with percent how many people comes from a given country
This commit is contained in:
parent
c7b1fb7e0f
commit
d7c3c77ef7
@ -11,6 +11,8 @@ read inWiek
|
|||||||
echo "Podaj kraj"
|
echo "Podaj kraj"
|
||||||
read inKraj
|
read inKraj
|
||||||
|
|
||||||
|
ile=0
|
||||||
|
wszyscy=0
|
||||||
|
|
||||||
# iterating line-by-line
|
# iterating line-by-line
|
||||||
while read line
|
while read line
|
||||||
@ -23,11 +25,17 @@ country=`echo $line | cut -d " " -f 3`
|
|||||||
if [ $name != "#" ]
|
if [ $name != "#" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
|
wszyscy=$((wszyscy+1))
|
||||||
|
|
||||||
if [ $country = "$inKraj" -a $age -ge $inWiek ]
|
if [ $country = "$inKraj" -a $age -ge $inWiek ]
|
||||||
then
|
then
|
||||||
|
ile=$((ile+1))
|
||||||
echo "Person $name (from $country) is $age years old"
|
echo "Person $name (from $country) is $age years old"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < $inPlik
|
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"
|
||||||
|
Loading…
Reference in New Issue
Block a user