Reputation: 378
User enters in an email. I use grep to check if the email already exists within a specific file.
Here's the part of the code that I'm having trouble with
$word = [user input (email) ]
legit = [boolean that is used for something else. No problem with that here]
I'm new. Help me kindly please.
if [[ grep -f "$word" "/root/Desktop/Dan/Logs/member-name-file" "$variable.txt" ]]
then
echo "Email already exists on requested List**"
legit=false
else
echo "Email added onto list**"
legit=true
fi
Upvotes: 1
Views: 130
Reputation: 785146
Instead of:
if [[ grep -f "$word" "/root/Desktop/Dan/Logs/member-name-file" "$variable.txt" ]]
You can do:
if grep -q "$word" "/root/Desktop/Dan/Logs/member-name-file"
Upvotes: 1