I needed run ngrep against some pcap files for domain names contained in a text file. I was able to accomplish this with the following;
However, it turns out the requirements were not explained clearly enough. Turns out the input file for the domain names is not just a text file with domain names but a tab delimited file with like 20 fields. So I need to bring in all the fields as something like $1, $2, $3, etc. This is needed in order to loop the search routine against $5 and then to write the output file with all the data from the input file when a match is made. Because the output my need to change, I would like to make each field a variable so I can make it look however I need to.
for i in `ls *.pcap`; do <domains.txt xargs -I % ngrep -t -i -W single -q % -I $i >>output.txt; done
However, it turns out the requirements were not explained clearly enough. Turns out the input file for the domain names is not just a text file with domain names but a tab delimited file with like 20 fields. So I need to bring in all the fields as something like $1, $2, $3, etc. This is needed in order to loop the search routine against $5 and then to write the output file with all the data from the input file when a match is made. Because the output my need to change, I would like to make each field a variable so I can make it look however I need to.