The problem with grep an user name in /etc/passwd is that the user name can be
similar to another string.
I would use id command to check the user existence, like :
Code:
if id $username > /dev/null 2>&1; then
echo "The name you have chosen already exist"
exit 1
fi