Reading input data in the console, not from arguments

This commit is contained in:
Arkadiusz Hypki 2023-05-15 17:38:24 +02:00
parent 476db26756
commit c7b1fb7e0f
1 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,14 @@
#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 plik z danymi"
read inPlik
echo "Podaj wiek"
read inWiek
echo "Podaj kraj"
read inKraj
# iterating line-by-line # iterating line-by-line
while read line while read line
do do
@ -15,11 +23,11 @@ country=`echo $line | cut -d " " -f 3`
if [ $name != "#" ] if [ $name != "#" ]
then then
if [ $country = "$2" -a $age -ge $3 ] if [ $country = "$inKraj" -a $age -ge $inWiek ]
then then
echo "Person $name (from $country) is $age years old" echo "Person $name (from $country) is $age years old"
fi fi
fi fi
done < $1 done < $inPlik