function one {
echo "Who is here?"
read name
echo "Who old are you $name?"
read age
if [ "$name" == "Sam" ]; then
Sam="$age"
else
Sam="26"
fi
if [ "$name" == "Jack" ]; then
Jack="$age"
else
Jack="49"
fi
echo "is there any one else ?"
read ans
if [ "$ans" == "yes" ]; then
one;
else
print;
fi
}
function print {
echo "Sam($Sam)"
echo "Jack($Jack)"
}
echo "Hi"
one;
The output is
Hi
Who is here?
Sam
Who old are you Sam?
43
is there any one else ?
yes
Who is here?
Jack
Who old are you Jack?
10
is there any one else ?
no
Sam(26)
Jack(10)
I don't want to overwrite the first input age. I want the output to have the new age for both names. so for the above input , I want the output to be:-
Sam(43)
Jack(10)