Merge branch 'master' of https://git.wmi.amu.edu.pl/ahypki/unixowe-systemy-operacyjne
This commit is contained in:
commit
d18ee6abe3
@ -4,14 +4,15 @@
|
|||||||
#numOfPeople=`cat $1 | grep $2 | wc -l`
|
#numOfPeople=`cat $1 | grep $2 | wc -l`
|
||||||
#echo "Num. of people from $2 is $numOfPeople"
|
#echo "Num. of people from $2 is $numOfPeople"
|
||||||
|
|
||||||
echo "Podaj nazwę pliku z bazą danych"
|
echo "Podaj plik z danymi"
|
||||||
read inPlikWej
|
read inPlik
|
||||||
echo "Podaj minimalny wiek"
|
echo "Podaj wiek"
|
||||||
read inWiek
|
read inWiek
|
||||||
|
echo "Podaj kraj"
|
||||||
|
read inKraj
|
||||||
|
|
||||||
w=0
|
ile=0
|
||||||
|
wszyscy=0
|
||||||
declare -A kraje
|
|
||||||
|
|
||||||
# iterating line-by-line
|
# iterating line-by-line
|
||||||
while read line
|
while read line
|
||||||
@ -24,16 +25,17 @@ country=`echo $line | cut -d " " -f 3`
|
|||||||
if [ $name != "#" ]
|
if [ $name != "#" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
w=$((w + 1))
|
wszyscy=$((wszyscy+1))
|
||||||
|
|
||||||
if [ $age -ge $inWiek ]
|
if [ $country = "$inKraj" -a $age -ge $inWiek ]
|
||||||
then
|
then
|
||||||
kraje["$country"]=$((kraje["$country"] + 1))
|
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 < $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"
|
||||||
|
Loading…
Reference in New Issue
Block a user