Loop with user input
by Masiel from LinuxQuestions.org on (#5E453)
Hi! I am very new to this and I am reaching a roadblock that I have no idea how to get around. I am trying to create a script that will prompt the user to enter First Name, Last Name, City until exit is entered in the First Name. Displayed like this
First Name: Jane
Last Name: Doe
City: Dayton
First Name: John
Last Name: Smith
City: Cincinnati
Jane Doe Dayton
John Smith Cincinnati
So far I have this:
until [[ $Fname = "exit" ]];
do
read -p 'First Name: ' Fname
read -p 'Last Name: ' Lname
read -p 'City: ' Cname
echo $Fname $Lname $Cname
However, its not stopping after First Name: exit, it continues to Last Name, City, then it echo, but only the second pass of the loop. How do I get it to echo both passes? And how do I get it to stop after exit is entered?
This is part an of assignment for class, and we are like 3 weeks in, so I am very new. If that info is needed. Thanks so much for your help!


First Name: Jane
Last Name: Doe
City: Dayton
First Name: John
Last Name: Smith
City: Cincinnati
Jane Doe Dayton
John Smith Cincinnati
So far I have this:
until [[ $Fname = "exit" ]];
do
read -p 'First Name: ' Fname
read -p 'Last Name: ' Lname
read -p 'City: ' Cname
echo $Fname $Lname $Cname
However, its not stopping after First Name: exit, it continues to Last Name, City, then it echo, but only the second pass of the loop. How do I get it to echo both passes? And how do I get it to stop after exit is entered?
This is part an of assignment for class, and we are like 3 weeks in, so I am very new. If that info is needed. Thanks so much for your help!