41 lines
736 B
Bash
Executable File
41 lines
736 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# iterating line-by-line over the input file
|
|
#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 kraj, który wyszukać"
|
|
read inKraj
|
|
echo "Podaj minimalny wiek"
|
|
read inWiek
|
|
|
|
w=0
|
|
sz=0
|
|
|
|
# iterating line-by-line
|
|
while read line
|
|
do
|
|
|
|
name=`echo $line | cut -d " " -f 1`
|
|
age=`echo $line | cut -d " " -f 2`
|
|
country=`echo $line | cut -d " " -f 3`
|
|
|
|
if [ $name != "#" ]
|
|
then
|
|
|
|
w=$((w + 1))
|
|
|
|
if [ $country = "$inKraj" -a $age -ge $inWiek ]
|
|
then
|
|
sz=$((sz + 1))
|
|
echo "Person $name (from $country) is $age years old"
|
|
fi
|
|
|
|
fi
|
|
|
|
done < $inPlikWej
|
|
|
|
echo "There is statistically `echo "scale=2; $sz/$w*100.0" | bc -l` % of such persons"
|