echo -e "Enter in a username : \c"
read username
grep "^$username:" /etc/passwd
What I'm trying to do is take in a username from my script and I need to be able to check if that username already exists. If it does the script should display a message saying that the user already exists and exit.
It's probably easy, but I am having a lot of trouble with it. I don't know how to structure my conditional properly.
grep "^$username:" /etc/passwd
This works fine with searching through the passwd file for the user, but how do I put this in the form of a conditional?
If anyone can help I would really appreciate it. Thanks.