Hi i am trying to do a bash script that checks if a username exists
echo "Enter desired username:"
read username
Search= true
while (Search= true)
do
getent passwd $username > /dev/null
if [ $? -eq 0 ]; then
echo "yes the user exists, try another username"
read username
Search= true
else
Search= false
echo "No, the user does not exist"
fi
done
If i type a username that exists it works as expected it runs the yes command ok
but if i type one that does not exists it enters an endless loop and keeps running "No, the user does not exist" and i have to close the terminal window
What have i done wrong here? Im only 8 weeks into a software development course.
If i type in a username that does not exist it endlessly prints
"No, the user does not exist"