Please help me with this script meant for checking /etc/passwd if a name exists

I'm trying to create a program that includes variety of duties. One of the duties includes deleting a user if the user name exist in the /etc/passwd file.

how do i make that happen. those of you that know about this shell programming, please tell me what i should do after the shell reads from the user input.

echo -n "Please enter name of user: "
read name

(what else)

thanks alot

FYI, although this resembles a classic homework problem, a review of the poster's history does not indicate student.

if [ "$name" ] ; then
   grep "^$name:" /etc/passwd > /dev/null &&
      userdel -r $name
fi

I really dont understand what your saying??

are you trying to say i want you to help me with my homework problem??? if so, well, am not

I taught my self shell programming and I feel i'm doing great compared to the fact that no one tutored me. i did this by myself.

i could have figured out the answer to the questioned i asked if i had time but i dont so i decided to ask

anyway, thanks

Don't get the wrong idea.

I have found that when people, not me, post "homework" questions that they might be answered if you actually post some code that shows that you have done the work and are just having problems working out the bugs.

If, as in some cases, users log in here and just want answers that is frowned upon.

If you have some code that you can post, that would be received more warmly.

Please, post away!

:wink:

Sorry for the confusion TRUEST. That FYI was not intended for you, but rather for all other readers of this thread. A very common homework assignment of late is creation of a menu-driven script that will do basic unix functions. I wanted to let the other readers (and potential repliers) know that, even though this looks like homework, I researched your posting history and saw that you are very much into real work, and not homework.