I am trying to create a logon program for users listed on a file. When I try to store the names into and array and check to see if they exist, I only return the header. So if I put NAME as the fname, it says it exists. But if I put Bob as fname, it says it doesn't. How do I store each first and last name into an array?
users.txt
NAME PASSWORD DEPT AUTH
Bob Jones 12345678 MKTG N
Sam Smith password MKTG Y
Pat Johnson 87654321 SALES N
Dina Shore drowssap OPS Y
Script
#!/bin/bash
FILE="users.txt"
read -p "Please enter first and last name: " fname lname
read -a name < $FILE
for name in "${name[0]}"
do
if [[ ${name[0]} = $fname ]]
then
echo "exist"
else
echo "Not Exist"
fi
done