$ awk 'FNR==NR{a[$1]=1;next} a[$3]==0' file1 FS='["|]+' file2
"b"|"124"|"ind"
"d"|"122"|"aus"
How it works:
file1 FS='["|]+' file2
This list of files tells awk to read file1
first, then change the field separator to any combination of double-quotes and vertical bars and then read file2.
FNR==NR{a[$1]=1;next}
FNR is the number of lines that awk has read from the current file and NR is the total number of lines read. Consequently, FNR==NR
is true only while reading the first file. The commands which follow in braces are only executed for the first file.
This creates an associative array a
whose keys are the first fields of file1
and whose values are 1. The next
command tells awk to skip the rest of the commands and start over on the next
line.
a[$3]==0
This is true only if the number in field 3 did not occur in file1. If it is true, then the default action is taken which is to print the line. (With the field separator that we have chosen, the number you are interested in is in field 3.)
Alternative
$ awk 'FNR==NR{a[$1]=1;next} a[substr($2,2,length($2)-2)]==0' file1 FS='|' file2
"b"|"124"|"ind"
"d"|"122"|"aus"
This is similar to the above except that the field separator is just a vertical bar. In this case, the number that you are interested in is in field 2. We use substr
to remove one character from either end of field 2 which has the effect of removing the double-quotes.