Skip to main content
1 of 2
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141

First, save a cat by not using one when you don't need it. Rather than:

cat haystack | grep needle

You can simply:

grep needle haystack

As for your script:

> results.txt  # start with a fresh file for every run
while read ip; do
    grep "$ip" *  | grep -Ev 'results\.txt|ips\.txt' >> results.txt
done < ips.txt

The grep-into-grep pipeline is to prevent adding entries from the input and output files into the output file.

DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141