Test....

hi! it's possible to test if a user exist or not? does exist something like -d for directories? i thought i could use getenv but i don't know how to use it for this purpose...

how can i verify if a variable is a number and not a generic string? i can't use regex, since i'm using bash shell :frowning:

thanks

Did you try,

ypcat passwd | grep -i <user>

Thanks
Nagarajan G

That's an extremely poor way of looking for a user, which is completly dependent on a NIS based environment.

getent passwd <username> > /dev/null 2>&1
if [[ $? -eq 0 ]] ;then
   echo "user exists"
else
   echo "user does not exist"
fi

:slight_smile: Thanks for your information

Nagarajan G