I'm trying to make a while loop. This loop should either echo "try again or type exit to quit" when typing gibberish or finger a user if typed the user name.
echo Please enter a user name to find.
read username
done_fn()
{
finger $username
exit 0
}
continue_fn()
{
echo 'try again or type exit to quit'
read exitvar
}
grep $username /etc/passwd >/dev/null
while [ $? -eq 0 ]
do
done_fn
done
exitvar=quit
until [ $exitvar = exit ]
do
continue_fn
done
while [ -u $exitvar ]
do
done_fn
done
This is everything I have got so far. Whenever I I type in a username after 'try again or type exit to quit' it will just echo it again. I would like it to finger the user instead of echoing it again. I have looked in so many places and can't find the answer.
Thank you in advance.
set -vxandset +vxto turn off. You'll see your code displayed, and then executed. Lines with + at the front show you what values have been substituted for variable names. In debug mode, all quoting is "boiled-down" by the debug/trace function to single quoting. You should see immediately what your problem is withgrepfollowed bywhile. Good Luck!{}format tool at the top left of the edit box on highlighted text to format as code/data/output. Again, good luck.