I need help with the following 1 display a status report tha
I need help with the following:
1. display a status report that contains the following information, in the order given:
A list of those users who are currently logged onto the system
The text: Please enter a user name to find.
2. Check for user: If the user types \"exit\" after the message \"Please enter a user name to find\", the program will terminate. If something other than \"exit\" is entered, the script will search to see If the user has an account on the system, and will display the line of information about the user.
Once the successful user was found the program will exit normally. If the user is not found the program will loop until the user either types exit or successfully enters a user name for someone with a Linux account.
NOTE: The user does not have to be on the system, but must have an account on the system - that is, they can be found in the /etc/passwd file.
NOTE 2: You may use just the person\'s last name in the search.
Solution
#!/bin/bash
echo \"CURRENT USERS\"
echo ————————————————————
log=`who`
use=`users`
echo \"$use\"
while true; do
echo \"Search the Name followed by [ENTER]:\"
read name
if [ \"$name\" == \"exit\" ]; then
echo Exiting
exit
fi
NAME=\"FALSE\"
for i in $log; do
if [ \"$i\" == \"$name\" ]; then
NAME=\"TRUE\"
break
fi
done
if [ \"$NAME\" == \"TRUE\" ]; then
rahul=`who | grep ${name}`
echo \"$rahul\"
fi
done
