ex1.sh script change to read input parameters from the user in command line
This commit is contained in:
parent
4aae9a0f24
commit
9748264474
@ -4,6 +4,13 @@
|
|||||||
#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 nazwę pliku z bazą danych"
|
||||||
|
read inPlikWej
|
||||||
|
echo "Podaj kraj, który wyszukać"
|
||||||
|
read inKraj
|
||||||
|
echo "Podaj minimalny wiek"
|
||||||
|
read inWiek
|
||||||
|
|
||||||
# iterating line-by-line
|
# iterating line-by-line
|
||||||
while read line
|
while read line
|
||||||
do
|
do
|
||||||
@ -15,11 +22,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 < $inPlikWej
|
||||||
|
Loading…
Reference in New Issue
Block a user