Two csv files formatted identically like this:
blah@domain.com,Elon,Tusk
I want to output the lines from the first file which match the same email address in the second file
Two csv files formatted identically like this:
blah@domain.com,Elon,Tusk
I want to output the lines from the first file which match the same email address in the second file
Instead of awk
, I use join
for this type of task because it's simpler/easier for me to remember e.g. join -t',' -o 1.1,1.2,1.3 <(sort -t',' -k1,1 first.csv) <(sort -t',' -k1,1 second.csv)
, although I believe that awk
is the best tool for this type of task, e.g. awk -F, 'FNR==NR {a[$1]; next}; $1 in a' second.csv first.csv