awk searching strings from file
6,886
Why search fields one-by-one? Why not search whole lines at a time?
grep -f find.txt path_to_100_files/*
![Jeff Schaller](https://lh4.googleusercontent.com/-wBY-4a1-0jo/AAAAAAAAAAI/AAAAAAAAAfc/4BCoMMK1rqg/photo.jpg?sz=256)
Author by
Jeff Schaller
Unix Systems administrator http://www.catb.org/esr/faqs/smart-questions.html http://unix.stackexchange.com/help/how-to-ask http://sscce.org/ http://stackoverflow.com/help/mcve
Updated on September 18, 2022Comments
-
Jeff Schaller almost 2 years
I'm currently using
$ awk 'NR==FNR{a[$1];next} ($3 in a)' find.txt path_to_100_files/*
which uses find.txt strings to search multiple files within path_to_100_files/ for matches.
find.txt contains
[email protected] [email protected]
and then path_to_100_files/ contains files such as
0.0.0.0:002921931:[email protected] 123.0.0.1:00029382:[email protected]
now what this is doing is only searching the 3rd column for the strings from find.txt, but i need it to search the entire file/every column?
as some files may be 5 columns long, or 9 columns long example,
0.0.0.0:002921931:1111111:[email protected] 123.0.0.1:00029382:1111111:11111:[email protected]
I've tried to change ($3 in a) to like ($0-$9 in a) but doesn't seem to work?
-
Wildcard over 6 yearsYou should add a
-F
as well for fixed-string search. -
done over 6 years@Wildcard As well as add a
-o
to only output matches.