Find whether the name entered by user exist in a file or not ?

p8.sh

#!/bin/bash

echo "Enter Username: "
read name

if grep "$name" /etc/passwd
then
    echo "User exist"
else
   echo "User doesnt exist"
fi

Post a Comment

Previous Post Next Post