I'm trying to compare two CSV files by reading the first line-by-line and grepping the second file for a match. Using Diff
is not a viable solution. I seem to be having a problem with having the email address stored as a variable when I grep the second file.
#!/bin/bash
LANG=C
head -2 $1 | tail -1 | while read -r line; do
line=$( echo $line | sed 's/\n//g' )
echo $line
cat $2 | cut -d',' -f1 | grep -iF "$line"
done
Variable $line contains an email address that DOES exist in file $2, but I'm not getting any results.
What am I doing wrong?
File1
Email
email@verizon.net
email@gmail.com
email@yahoo.com
File2
email,,,,
email@verizon.net,,,,
email@gmail.com,,,,
email@yahoo.com,,,,