I'd like to eliminate the rows in two files that do not share a common value in the first column. Here's my tortured logic that is way too inefficient to consider, but might show what i'm trying to do (assume the files have been sorted):
Thanks folks, what I eventually ended up with was:
awk -F'|' 'NR==FNR{++a[$1];next} $1 in a' file1 file2> first.dat
awk -F'|' 'NR==FNR{++a[$1];next} $1 in a' file2 file1> second.dat
comm -13 second.dat first.dat > final.dat
I should add that the various options involving grep -f were too time consuming given the size of the files, something I should have mentioned at the outset.