2023-05-08 16:18:28 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# iterating line-by-line over the input file
|
2023-05-08 16:50:11 +02:00
|
|
|
#numOfPeople=`cat $1 | grep $2 | wc -l`
|
|
|
|
#echo "Num. of people from $2 is $numOfPeople"
|
2023-05-08 16:18:28 +02:00
|
|
|
|
2023-05-08 16:50:11 +02:00
|
|
|
# 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`
|
2023-05-08 17:03:43 +02:00
|
|
|
|
|
|
|
if [ $name != "#" ]
|
|
|
|
then
|
|
|
|
|
|
|
|
if [ $country = "$2" -a $age -ge $3 ]
|
|
|
|
then
|
|
|
|
echo "Person $name (from $country) is $age years old"
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
2023-05-08 16:50:11 +02:00
|
|
|
|
|
|
|
done < $1
|