title: How to use find command with sed and awk to remove duplicate IP from files
body: <p>Howdie do,</p>
  
  <p>I'm writing a script that will remove duplicate IP's from two files. For example,</p>
  
  <pre><code> grep -rw "123.234.567" /home/test/ips/
   /home/test/ips/codingte:123.234.567
   /home/test/ips/codingt2:123.234.567
  </code></pre>
  
  <p>Ok, so that IP is in two different files and so I need to remove the IP from the second file.</p>
  
  <p>The grep gives me the file path and the IP address. My thinking: store the file path in a variable with awk and then use find to go to that file and use sed to remove the duplicate IP, so I changed my grep statement to:</p>
  
  <pre><code> grep -rw "123.234.567" . | awk -F ':' '{print $1}'
  </code></pre>
  
  <p>which returns:</p>
  
  <pre><code> ./codingte
   ./codingt2
  </code></pre>
  
  <p>I originally tried to use the fully pathname in the find command, but that didn't work either</p>
  
  <pre><code> find -name /var/cpanel/dips/codingte -exec sed '/123.234.567/d' {} \;
  </code></pre>
  
  <p>So, I just did a CD in the directory and changed the find command to:</p>
  
  <pre><code> find -name 'codingt2' -exec sed '/123.234.567/d' {} \;
  </code></pre>
  
  <p>Which runs, but doesn't delete the IP address:</p>
  
  <pre><code> cat codingt2
   123.234.567
  </code></pre>
  
  <p>Now, I know the issue is with the dots in the IP address. They need to be escaped, but I'm not sure how to do this. I've been reading for hours on escaping the regex, but I'm not sure how to do this with sed</p>
  
  <p>Any help would be appreciated. I'm just trying to learn more about regex and using them with other linux tools such as awk and find.</p>
  
  <p>I haven't written the full script yet. I'm trying to break it into pieces and then bring it together in the script.</p>
  
  <p>So you know what the output should look like:</p>
  
  <pre><code> codingte
   123.234.567
  
   codingt2
  </code></pre>
  
  <p>The second file would just have the IP removed</p>