diff --git a/tabledata/ex1.sh b/tabledata/ex1.sh index 800591c..04162d0 100755 --- a/tabledata/ex1.sh +++ b/tabledata/ex1.sh @@ -1,6 +1,25 @@ #!/bin/bash # iterating line-by-line over the input file -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" +# 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 + +if [ $country = "$2" -a $age -ge $3 ] +then + echo "Person $name (from $country) is $age years old" +fi + +fi + +done < $1