title: Evaluating command with Awk
body: <p>The problem is that: I have different txt files in which is registered a timestamp and an ip address for every malware packet that arrives to a server. What I want to do is create another txt file that shows, for every ip, the first time a malware packet arrives. </p>
  
  <p>In general I want to do something like this :</p>
  
  <pre><code>for every  line in file.txt
   if (ip is not present in list.txt)
   copy timestamp and ip in list.txt
  </code></pre>
  
  <p>I'm using awk for doing it. The main problem is the "if ip is not present in list.txt".
  I'm doing this:</p>
  
  <pre><code> {    a=$( grep -w "$3" list.txt | wc -c );
      if ( a == 0 )
     {
       #copy timestamp and ip in list.txt
     }
  </code></pre>
  
  <p>( i'm using $3 because the ip address is in the third column of the source file )</p>
  
  <p>I don't know how to make awk evaluate the grep function. I've tried with backticks also but it didn't work. Someone could give me some hint?</p>
  
  <p>I'm testing my script on test file like this:</p>
  
  <pre><code>10  192.168.1.1
  11  192.168.1.2
  12  192.165.2.4
  13  122.11.22.11    
  13  192.168.1.1
  13  192.168.1.2
  13  122.11.22.11
  14  122.11.22.11
  15  122.11.22.11
  15  122.11.22.144
  15  122.11.2.11
  15  122.11.22.111
  </code></pre>
  
  <p>What should I obtain is:</p>
  
  <pre><code>10  192.168.1.1
  11  192.168.1.2
  12  192.165.2.4
  13  122.11.22.11    
  15  122.11.22.144
  15  122.11.2.11
  15  122.11.22.111
  </code></pre>
  
  <p><strong>Thanks to your help I've succeded in creating the script that fits my needs :</strong></p>
  
  <pre><code>awk '
  FILENAME == ARGV[1] {
      ip[$2] = 1
      next
  }
  ! ($2 in ip) {
      print $1, $2 &gt;&gt; ARGV[1]
      ip[$2] = 1
  }
  ' list.txt file.txt 
  </code></pre>