Suppose I have a file input.txt
with few columns and few rows, the first column is the key, and a directory dir
with files which contain some of these
Use process substitution to create a keyword "file" that you can pass to grep
via the -f
option:
grep -f <(awk '{print $1}' input.txt) dir/*
This will search each file in dir
for lines containing keywords printed by the awk
command. It's equivalent to
awk '{print $1}' input.txt > tmp.txt
grep -f tmp.txt dir/*