Reputation: 839
the following command returns only matches from file2.
grep -f file1 file2
How is it possible to print match line from the first file (file1) following the second match from file2?
Upvotes: 0
Views: 54
Reputation: 203324
awk 'NR==FNR{res[$0]; next}
{
found = 0
for (re in res) {
if ($0 ~ re) {
print "found:", re
found = 1
}
}
}
found
' file1 file2
Upvotes: 3