Thursday, June 21, 2018

Write a shell script which checks whether a given user is valid or not - OS

read user
echo
echo "Validating the $user ..."
if [ `grep -c $user /etc/passwd` -eq 0 ]
then
echo
echo "ERROR : PLEASE ENTER A VALID USERNAME."
echo "Exiting ..."
else
echo "Valid user "
fi

No comments:

Post a Comment