I'm trying to use awk to print the lines contained in one file2 if the numbers in column 1 or 5 is in file1, but I'm getting a syntax error that I don't understand.
My input is:
file1.dat
1
3
4
6
8
13
14
25
etc...
file2.dat
2 GLU 1 - 3 ARG 2
24 ASP 2 - 12 LYS 1
3 ASP 1 - 25 ARG 2
7 LYS 2 - 17 GLU 2
18 ARG 1 - 13 GLU 2
etc...
In this case I want the output
2 GLU 1 - 3 ARG 2
3 ASP 1 - 25 ARG 2
18 ARG 1 - 13 GLU 2
I tried to do this with the following awk-line
awk -F 'NR==FNR{a[$1||$5]++;next} (a[$1||$5])' file1.dat file2.dat
but I get the error
awk: file1.dat
awk: ^syntax error
Does anyone know what is causing this error? I have tried to put the file names into variables but that produces the same error.