From 2f7b833d0946bb3572963010aaad14f950fc489e Mon Sep 17 00:00:00 2001 From: Arkadiusz Hypki Date: Mon, 8 May 2023 16:50:11 +0200 Subject: [PATCH 1/2] backup; --- tabledata/ex1.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tabledata/ex1.sh b/tabledata/ex1.sh index 588322b..e08b7be 100755 --- a/tabledata/ex1.sh +++ b/tabledata/ex1.sh @@ -1,6 +1,16 @@ #!/bin/bash # iterating line-by-line over the input file -numOfPeople=`cat $1 | grep 'Poland' | wc -l` +#numOfPeople=`cat $1 | grep $2 | wc -l` +#echo "Num. of people from $2 is $numOfPeople" -echo "Num. of people from Poland 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` +echo "Person $name (from $country) is $age years old" + +done < $1 From 4aae9a0f24e72aadeef0428757279a81bae85621 Mon Sep 17 00:00:00 2001 From: Arkadiusz Hypki Date: Mon, 8 May 2023 17:03:43 +0200 Subject: [PATCH 2/2] Script for looking for people of specific age and country done; --- tabledata/ex1.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tabledata/ex1.sh b/tabledata/ex1.sh index e08b7be..04162d0 100755 --- a/tabledata/ex1.sh +++ b/tabledata/ex1.sh @@ -11,6 +11,15 @@ do name=`echo $line | cut -d " " -f 1` age=`echo $line | cut -d " " -f 2` country=`echo $line | cut -d " " -f 3` -echo "Person $name (from $country) is $age years old" + +if [ $name != "#" ] +then + +if [ $country = "$2" -a $age -ge $3 ] +then + echo "Person $name (from $country) is $age years old" +fi + +fi done < $1