unix - awk : lines in file.txt that match any of the strings in file -


i have 2 separate .txt files:

list.txt, containing list of strings:

string1 string2 string3 

and entries.txt, containing different lines 7 fields

name field2 field3 field4 field6 string1 field8 

i need lines entries.txt 7th fields == 1 of lines in list.txt.

i know grep, grep -f list.txt entries.txt, need in 7th field, wanted use awk.

so awk '$7==$(any string list.txt)'

how can write $(any string list.txt) part?

try awk one-liner:

awk 'nr==fnr{a[$0];next}$7 in a' list.txt entries.txt 

didn't test, should work requirement.

note : $6 or $7 ?

you said in question, should $7, used $7. @ example, seems should $6 ? anyway, change column index yourself.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -