Comparing two files

Alright, so I'm pretty bad at this

What I'm trying to do is take 2 files I have, with data separated by tabs, and compare it to a much larger list of data and pull out any matches into a 3rd file

For example, File 1 has value A in column 1, I wanna search column 1 of file 2 for any instances of A (there should be 2 instances), and then print the data from file 2 (basically the whole row of data that A is in) to a second file, then repeat the process for the rest of column 1 in file A

Any ideas? I'm looking at using awk and making a bash script for it

try:

awk -F'    '  'FILENAME=="file1" {arr[$1]++; next}
                 FILENAME=="file2"  { if( $1 in arr) {print $0} } '  file1 file2  > newfile

the -F' ' thing is -Ftic[tab key]tic ... since tab doesn't show because it is a whitespace value. tic is a single quote

I could be missing something, but the output file is completely blank

Try (Remove -F switch. default field separator is space and tab, so -F is not really needed)

 
awk  'FILENAME=="file1" {arr[$1]++; next} FILENAME=="file2"  { if( $1 in arr) {print $0} } '  file1 file2  > newfile

OR

 
awk  'NR==FNR{arr[$1]++; next} { if( $1 in arr) {print $0} } '  file1 file2  > newfile